Re: fminsearch
- From: "John D'Errico" <woodchips@xxxxxxxxxxxxxxxx>
- Date: Thu, 16 Apr 2009 23:19:02 +0000 (UTC)
"Andrea Asoni" <andrea.asoni@xxxxxxxxx> wrote in message <gs8aqp$1u6$1@xxxxxxxxxxxxxxxxxx>...
maybe i got the code all wrong (it is my third day of self-thought matlab!) but z and b are scalars.
p(i,1) is defined as the (i,1)th element of vector x times z plus the (i,1)th element of vector y times b.
i want to maximize (with respect to z and b) the function L which is the sum of all the p's (who should be functions of z,b and the 'data' x,y)...
does it make any sense? did i get it all wrong?
Sorry, but I don't buy it. ;-)
MATLAB does not lie, so it must be you who
are mistaken here.
Read the error message.
??? Subscripted assignment dimension mismatch.
Error in ==> maxlik at 6
p(i,1)=z*x(i,1)+b*y(i,1);
It refers to the line above. Since i is a scalar,
defined by the for loop above it, we know that
p(i,1) is a scalar.
Likewise, x(i,1) and y(i,1) are scalars. If either
of them were empty, then you should have
gotten a different error message.
You can only have an assignment mismatch if
the result on the right hand side of this expression
is not a scalar. There are two ways for that to
happen. The right hand side must be either an
empty array, or it must be a vector or an array.
It will be empty if either of z or b is empty, or
if they are vectors or matrices.
You need to use the debugger to identify which
is happening. Also, as I said in my first response,
learn to do without the globals. This may well
be one of the reasons you have this error in the
first place. It is very easy to have a variable
stepped on without your realizing it.
John
.
- Follow-Ups:
- Re: fminsearch
- From: Andrea Asoni
- Re: fminsearch
- References:
- fminsearch
- From: Andrea Asoni
- Re: fminsearch
- From: John D'Errico
- Re: fminsearch
- From: Andrea Asoni
- fminsearch
- Prev by Date: Re: icon image for special file types
- Next by Date: Looking for a microprocessor working with Simulink
- Previous by thread: Re: fminsearch
- Next by thread: Re: fminsearch
- Index(es):
Relevant Pages
|