Why my fminsearch do not work?

1 view (last 30 days)
Alberto
Alberto on 10 Jul 2013
Hi all! I would like to know why my fminsearch function do not work. The error that I received is: Subscripted assignment dimension mismatch.
Subscripted assignment dimension mismatch.
Error in fminsearch (line 191)
fv(:,1) = funfcn(x,varargin{:});
Error in GINO_programme (line 62)
[A,fval,exitflag] = fminsearch(@GINO_function,y0,options);
the script is:
I FILE
function BA=GINO_function(A)
global DB_temp r T mv_equity_t sig_E
V= A(1,1);
sig_v= A(2,1);
d1=log(V/DB_temp)+(r+(0.5*(sig_v).^2))*T/(sig_v*sqrt(T));
d2=d1-(sig_v*sqrt(T));
BA(1,1)=mv_equity_t- V*normcdf(d1)+ DB_temp*exp(-(r*T))*normcdf(d2);
BA(2,1)=sig_E* mv_equity_t-normcdf (d1)*sig_v*V;
II FILE
options = optimset('Display','iter');
[A,fval,exitflag] = fminsearch(@GINO_function,y0,options);
I used to run this program fsolve but eh sintax of fsolve and fminsearch is the same no? Why matlab creates this error if with fsolve works? Thank you a lot

Answers (1)

Matt J
Matt J on 10 Jul 2013
I used to run this program fsolve but eh sintax of fsolve and fminsearch is the same no?
No, fminsearch works with a scalar objective function. Try this instead
[A,fval,exitflag] = fminsearch(@(y) norm(GINO_function(y)),y0,options);

Categories

Find more on Financial Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!