|
On Jan 28, 10:13=A0pm, Nitin <nitin.k.gu...@gmail.com> wrote:
> On Jan 28, 11:42 am, fas <faisalmu...@gmail.com> wrote:
>
> > I have written my objective function. However I have to run a loop. I
> > am wondering if I can write it without a loop. Here X is a 3x1000
> > matrix and Y is a scalar. In each loop it takes X(3,1) and create one
> > equation.
>
> > function f =3D objfun(x,X,Y)
>
> > for i=3D1:1000
> > =A0 =A0 f=3D(X(:,i)*X(:,i)')*[x(1),x(2),x(3)]'-Y(i)*X(:,i);
> > end
> > f=3Dnorm(f);
>
> did you mean that Y is a "vector"? and, it takes "x(3,1)" in each
> loop?
>
> shouldn't your equation look like:
> f(i)=3D(X(:,i)*X(:,i)')*[x(1),x(2),x(3)]'-Y(i)*X(:,i);
>
> Nitin
> --
> ni...@idearesearch.inwww.idearesearch.in
Sorry I made a mistake it should have been like that
f(:,i)=3D(X(:,i)*X(:,i)')*[x(1),x(2),x(3)]'-Y(i)*X(:,i);
and Y is a 1000x1 vector
|