On Monday, November 11, 2013 8:16:09 AM UTC+13, Marc wrote:
> "azira" wrote in message <l5nejp$qqa$1@newscl01ah.mathworks.com>...
>
> > hey guys, please check whether my calculation is correct or not.
>
> >
>
> > question : F(x) = max {b(i) *(summation j=1 until 5 )(x(j)a(ij))^2} ; i=1=10 ; j=15
>
> >
>
> >
>
> > a = [ 0 0 0 0 0; 2 1 1 1 3; 1 2 1 1 2; 1 4 1 2 2; 3 2 1 0 1; 0 2 1 0 1; 1 1 1 1 1; 1 0 1 2 1; 0 0 2 1 0; 1 1 2 0 0];
>
> > b = [ 1;5;10;2;4;3;1.7;2.5;6;3.5]
>
> > x(1)=0; x(2)=0;x(3)=0;x(4)=0; x(5)=1;
>
> >
>
> > sum=0;
>
> > for j = 1:5
>
> > for i = 1:10
>
> > sum = sum +( (x(j)a(i, j))^2);
>
> > end
>
> > end
>
> > sum
>
> >
>
> > for i=1:10
>
> > f= b(i) * sum
>
> > end
>
>
>
> On another note, you should not use "sum" as a dummy variable, since it is a function within Matlab.
>
>
>
> doc sum.....
Also, the final loop is ineffective.
You could replace it with:
f=b(10)*sum
In addition to not using sum as a variable, you should avoid using i and j as well  by default, they are sqrt(1).
