Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


Math Forum » Discussions » Software » comp.soft-sys.matlab

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

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Andrea Asoni

Posts: 10
Registered: 4/15/09
fminsearch
Posted: Apr 16, 2009 5:18 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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?



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.