title: How do i mathematically apply a window function to a signal in matlab?
body: <p>I am currently trying to make a plot of a windowed signal.  The plot is currently been made in latex, but  can't seem to recreate the plot generated in matlab in latex. </p>
  
  <pre><code>   %% Time specifications:
     Fs = 8000;                   % samples per second
     dt = 1/Fs;                   % seconds per sample
     StopTime = 60;             % seconds
     t = (0:dt:StopTime-dt)';     % seconds
     %% Sine wave:
     Fc = 60;                     % hertz
     x = sin(0.9*pi*t) + sin(0.42*pi*t);
     %x = cos(2*pi*Fc*t) + cos(2*pi*Fc*5*t)+ sin(2*pi*Fc*10*t);
     % Plot the signal versus time:
     figure;
     %plot(t,x);
     %xlabel('time (in seconds)');
     %title('Signal versus Time');
     %zoom xon;
     %%
     window = hamming(length(t),'periodic');
     %plot(window)
     windowed = x.*window; 
     plot(windowed)
  </code></pre>
  
  <p>This generates a plot like this</p>
  
  <p><a href="https://i.stack.imgur.com/Wcl1P.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Wcl1P.jpg" alt="enter image description here"></a></p>
  
  <p>But when i tries to recreate the plot in <strong>matlab</strong>.. I get something way different. </p>
  
  <p>What I am plotting is this :</p>
  
  <pre><code>w= sin(0.9*pi*t) + sin(0.42*pi*t)*0.54 - 0.46*( cos(360*t/600))
  plot(w)
  </code></pre>
  
  <p>First part being the signal * window = windowed signal...
  And what I get is this..</p>
  
  <p><a href="https://i.stack.imgur.com/ai1Y8.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ai1Y8.jpg" alt="enter image description here"></a></p>
  
  <p>Why is this so different.. What am I doing wrong?</p>