title: Matlab: iterating over a vector to give taylor expansion for each element
body: <p>I'm attempting to iterate over a vector <code>y</code>, using 2 nested <code>for</code> loops, to return a list of the sum of the taylor expansion for each number in the vector.</p>
  
  <p>It keeps returning the error</p>
  
  <blockquote>
    <p>In an assignment A(:) = B, the number of elements in A and B must be the same. </p>
  </blockquote>
  
  <p>Code:</p>
  
  <pre><code>n = 6 
  y = zeros(1,n);
  x = [0.785398,0.392699,0.19635,0.098175];
  
  for i = (1:4)
  
      for i = 0:n
  
          y(i+1) = (-1).^i*x.^(2*i+1)/factorial(2*i+1); 
  
      end;
  
      SINx = sum(y)
  
  end
  </code></pre>