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
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 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by