Running a code on multiple input files and get results
Afficher commentaires plus anciens
Hi all,
find below the code I am using to analyze a hydraulic network (the toolkit I am using links the hydraulic software EPANET with Matlab provided):
clear; close('all'); clc;
start_toolkit;
d = epanet('BWSN_flush1(0-1).inp'); %load the network
basedemand=d.getNodeBaseDemands;
idx = find(basedemand{1,1}~= 0);
nnodes=numel(idx)
qual_res = d.getComputedQualityTimeSeries;
qual_res.NodeQuality(~mod(qual_res.Time,3600)==0,:)=[];
T=0:1:240;
for i=1:nnodes
qual=qual_res.NodeQuality(:,idx)';
res=[[NaN T]; [idx'-1 qual]];
end
xlswrite('flush1(0-1)',res) %write results
Since I have to run this code several times (e.g. BWSN_flush1(1-2),BWSN_flush1(2-3),BWSN_flush1(3-4),BWSN_flush2(0-1) and others), is there any way to automate the code so that for each file input file.inp it gives me a file.xls (it would be great if this file gets the same name of the .inp one).
So at this time I have to run the following inp files:
BWSN_flush1(0-1), BWSN_flush1(1-2), BWSN_flush1(3-4), BWSN_flush1(5-6) , BWSN_flush1(7-8) BWSN_flush1(9-10) BWSN_flush1(11-12) BWSN_flush1(12-13) BWSN_flush1(13-14) BWSN_flush1(14-15) BWSN_flush1(15-16) BWSN_flush1(16-17) BWSN_flush1(17-18) BWSN_flush1(18-19) BWSN_flush1(19-20) BWSN_flush1(20-21) BWSN_flush1(21-22) BWSN_flush1(222-23) BWSN_flush1(23-24) BWSN_flush2(0-1) BWSN_flush2(0-1) BWSN_flush2(0-1) BWSN_flush2(0-1) BWSN_flush2(0-1) BWSN_flush2(0-1) BWSN_flush2(0-1) BWSN_flush2(0-1) BWSN_flush2(0-1) BWSN_flush2(1-2) BWSN_flush2(2-3) BWSN_flush2(3-4) BWSN_flush2(5-6) BWSN_flush2(6-7) BWSN_flush2(7-8) BWSN_flush2(8-9) BWSN_flush2(9-10) BWSN_flush2(10-11) BWSN_flush2(11-12).
Thanks,
Stefania
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Data Import from MATLAB dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!