Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: fminsearch
Replies: 7   Last Post: Apr 17, 2009 12:11 PM

 Messages: [ Previous | Next ]
 Andrea Asoni Posts: 10 Registered: 4/15/09
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?

Date Subject Author
4/16/09 Andrea Asoni
4/16/09 jrenfree@gmail.com
4/16/09 John D'Errico
4/16/09 John D'Errico
4/16/09 Andrea Asoni
4/16/09 John D'Errico
4/17/09 Andrea Asoni
4/16/09 jrenfree@gmail.com