필터 지우기
필터 지우기

How to save each iteration of nested for loops?

조회 수: 1 (최근 30일)
Vert
Vert 2014년 12월 6일
답변: Stalin Samuel 2014년 12월 6일
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

채택된 답변

Stalin Samuel
Stalin Samuel 2014년 12월 6일
ErrRMSE(step1,step2,step3,step4,step5) = sqrt(sum((Difference).^2)/1099);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by