Problem with nested function structure by using "fminsearch" command.

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 Comment

I believe there is something wrong in the way i have organized the nested function structure.
What leads you to believe that?

Sign in to comment.

Answers (0)

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Asked:

on 21 Feb 2014

Commented:

on 21 Feb 2014

Community Treasure Hunt

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

Start Hunting!