Prev: In an assignment A(I) = B, the number of elements in B and I must be the same.
Next: how to create a zoom out plot within a plot
From: Kunal Matharu on 20 Sep 2009 17:05 m=5; z=1:m; x=1:(m+1); x(1)=0; for k=1:m x(k+1)= k*(1/m); z(k)=((x*(k))+(x*(k+1)))/2; end sum(z); ??? In an assignment A(I) = B, the number of elements in B and I must be the same. I get a weird msg but i dont see where i went wrong can anyone help me out.
From: Jos on 21 Sep 2009 04:03
"Kunal Matharu" <kunal.matharu(a)hotmail.com> wrote in message <h965ef$a8u$1(a)fred.mathworks.com>... > m=5; > z=1:m; > x=1:(m+1); > x(1)=0; > > for k=1:m > x(k+1)= k*(1/m); > z(k)=((x*(k))+(x*(k+1)))/2; > end > sum(z); > > ??? In an assignment A(I) = B, the number of elements in B and > I must be the same. > > > I get a weird msg but i dont see where i went wrong can anyone help me out. The stars here looks suspicious: ((x*(k))+(x*(k+1)))/2 making this a vector instead of a scalar Perhaps this is what you meant: (x(k) + x(k+1))/2 hth Jos |