
fminsearch
Posted:
Apr 16, 2009 5:18 PM


hi,
i have some problems with fminsearch. i am trying to make it work on a simple example (similar in structure to my far more complicated problem) but still can't.
I have the following function:
%maxlik.m function L=maxlik(z,b) global x y N ev z b;
for i=1:N; if ev(i,1)==1; p(i,1)=z*x(i,1)+b*y(i,1); else p(i,1)=z*x(i,1)+b^2*y(i,1); end end L=sum(p) end
and i have the following main program: id=m(:,1); ev=m(:,2); x=m(:,3); y=m(:,4); c=m(:,5); te=m(:,6); N=length(c);
%initial conditions z0=1; b0=1; global x y N ev z b;
[z,b]=fminsearch(@maxlik,[z0,b0]);
but when i run it i get the following error message...
??? Subscripted assignment dimension mismatch.
Error in ==> maxlik at 6 p(i,1)=z*x(i,1)+b*y(i,1);
Error in ==> fminsearch at 175 fv(:,1) = funfcn(x,varargin{:});
Error in ==> prova at 29 [z,b]=fminsearch(@maxlik,[z0,b0]);
what does it mean? what's the error?

