Borrar filtros
Borrar filtros

How to save each iteration of nested for loops?

1 visualización (últimos 30 días)
Vert
Vert el 6 de Dic. de 2014
Respondida: Stalin Samuel el 6 de Dic. de 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

Respuesta aceptada

Stalin Samuel
Stalin Samuel el 6 de Dic. de 2014
ErrRMSE(step1,step2,step3,step4,step5) = sqrt(sum((Difference).^2)/1099);

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by