Problem with nested function structure by using "fminsearch" command.
조회 수: 3 (최근 30일)
이전 댓글 표시
Hello,
I'm trying to minimize a function which is RMSE between two data series of temperature measured and calculated. I believe there is something wrong in the way i have organized the nested function structure. Below i carry over a shortened version of the script, thank you very much.
function [x,lambda_filt,lambda]=prova1(x,TRT)
%TRT is the matrix i need to bring all data specially the temperatre measured
opt = optimset ( 'Display' , 'iter','MaxIter' ,2 );
[x, fval, exitflag, output] = fminsearch ( @margin,x,opt )
function w=margin(x)
for index=1:length(tempo) % tempo is inside TRT
T_calculated(index)= (Q/H)./(4.*pi.*sqrt(x(1).*x(1))).*exp( (row.*cw.*q.*r_bw)./ (2.*x(1) )).*quad(@(phi) (exp(-phi-(((r_bw.^2)./x(1)) + ((r_bw.^2)./x(1))).*(((row.*cw.*q).^2)./(16.*x(1).*phi))).*(1./phi)),0,(((row.*cw.*q).^2).*tempo(index))./(4.*ro.*c.*x(1)))+x(2)+((Q/H)*Rb);
end
misfit=(T_calculated-T_measured).^2;
w= sqrt(sum(misfit)./length(tempo));
end
figure;
plot(tempo,T_calculated,tempo,T_measured,'r');
end
댓글 수: 1
Matt J
2014년 2월 21일
I believe there is something wrong in the way i have organized the nested function structure.
What leads you to believe that?
답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!