title: Matlab error: In an assignment A(I) = B, the number of elements in B and I must be the same
body: <p>I have an array of size 9 <code>b</code> and i am attempting at assigning values into it.</p>
  
  <pre><code>r=a(7)+u*(b(8))+v*(b(9))
  b(7)=r
  </code></pre>
  
  <p>I get that <code>r</code> is indeed a 1X1 value but yet for <code>b(7)=r</code> i still get:</p>
  
  <pre><code>Error in ==&gt; myFunction at 37
      b(7)=r
  
  In an assignment  A(I) = B, the number of elements in B and
  I must be the same.
  </code></pre>
  
  <p>The following is the code of myFunction (the for loop with % is what i would have liked to work)</p>
  
  <pre><code>function b=myFunction(u,v,a)
      b(8)=0;
      b(9)=0
      r=a(7)+u*(b(8))+v*(b(9));
      size(a)
      size(b)
      size(r)
      b(7)=r
      r=a(6)+u*b(6+1)+v*b(6+2);
      b(6)=r;
      b(5)=a(5)+u*b(5+1)+v*b(5+2);
      b(4)=a(4)+u*b(4+1)+v*b(4+2);
      b(3)=a(3)+u*b(3+1)+v*b(3+2);
      b(2)=a(2)+u*b(2+1)+v*b(2+2);
      b(1)=a(1)+u*b(1+1)+v*b(1+2);
      %for i=7:-1:1
      %    b(i)=a(i)+u*b(i+1)+v*b(i+2);
      %end
  end
  </code></pre>