How to save hydraulic variables from different scenarios in matlab workspace?

I’m trying to save the roughness, pressure, flow in different scenarios in the matlab Do you have a simple command to do it?

Hi @annelo,

You can try the following example:

start_toolkit; 

d = epanet('Net1.inp');

scenarios = 5;

% save
P = struct(); % P - parameters
for i=1:scenarios
    
    P.roughness = d.getLinkRoughnessCoeff;
    P.elevations = d.getNodeElevations-d.getNodeElevations*rand(1)*0.5;
    d.setNodeElevations(P.elevations)
    res = d.getComputedTimeSeries;
    save(['scenario',num2str(i),'.sc'],'res', 'P', '-mat');

end

% load 
for i=1:scenarios
    load(['scenario',num2str(i),'.sc'],'res', 'P', '-mat');
    res.Pressure(1,:)
    P.elevations
end

d.unload;

Source: Sensor Placement (S-PLACE) Matlab Toolkit - https://github.com/KIOS-Research/splace-toolkit

https://github.com/KIOS-Research/splace-toolkit/blob/master/SPLACE/SIMULATE/SimulateAll/runMultipleScenarios.m

Thanks,
Marios

1 Like

It helped a lot!
Thanks! S2