title: multiplying sin waves / cos waves recursively in a loop in matlab / octave
body: <p>I'm trying to multiply sin waves / cosine waves recursively but I'm not sure why my answers are so different.  <em>Y2</em> in <strong>blue</strong> is what I'm trying to get but the FOR loop which is <em>Y</em> in <strong>red</strong> is what is produced any idea how to fix the FOR loop <em>Y</em>? see plot and code below ?</p>
  
  <pre><code>Fs = 8000;% Sampling frequency
  t=linspace(0,1,Fs);
  
  y=zeros(1,length(t));
  y = .5*sin(2*pi*2*t); 
  for ii=1:1:3    
      y=y.*y; 
  end
  plot(y,'r') 
  hold on
  
  y2=(.5*sin(2*pi*2*t)).* (.5*sin(2*pi*2*t)).*(.5*sin(2*pi*2*t)); %should look like this
  plot(y2,'b') %both plots should look like this
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/NYry9.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NYry9.jpg" alt="Plot"></a>
  PS:  I'm using octave 3.8.1 which is like matlab</p>