How to save each iteration of nested for loops?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Vert
am 6 Dez. 2014
Beantwortet: Stalin Samuel
am 6 Dez. 2014
I have a function with 5 parameters. I am trying to run the function varying each parameter within their given ranges. I need to find the error associated with each combination of the 5 parameters so I need to save the error for each iteration. Currently, it overwrites it, leaving me with only the last value. Thank you for your help!
Code:
% CMAX b ALPHA Ks Kq
MinB = [1.0 0 0 .0002 .1]; % minimum boundary
MaxB = [1000 2.0 1 .10 .99]; % maximum boundary
resolution = 3;
pcmax = (1: ((1000-1)/resolution): 1000);
pb = (0: ((2-0)/resolution): 2);
palpha = (0: ((1-0)/resolution): 1);
pks = (.0002: ((.1-.0002)/resolution): .10);
pkq = (.1: ((.99-.1)/resolution): .99);
Pars = zeros(3,3,3,3,3);
for step1=1:4
for step2=1:4
for step3=1:4
for step4=1:4
for step5=1:4
Pars = [pcmax(step1) pb(step2) palpha(step3) pks(step4) pkq(step5)];
[SimFlow] = HyMod(Pars,PET,Precip); % Run model
Difference = abs(ObsFlow - SimFlow);
ErrRMSE = sqrt(sum((Difference).^2)/1099);
end
end
end
end
end
0 Kommentare
Akzeptierte Antwort
Stalin Samuel
am 6 Dez. 2014
ErrRMSE(step1,step2,step3,step4,step5) = sqrt(sum((Difference).^2)/1099);
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!