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.
%% 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;
%xlabel(‘time (in seconds)’);
%title(‘Signal versus Time’);
window = hamming(length(t),’periodic’);
windowed = x.*window;
This generates a plot like this
But when i tries to recreate the plot in matlab.. I get something way different.
What I am plotting is this :w= sin(0.9*pi*t) + sin(0.42*pi*t)*0.54 – 0.46*( cos(360*t/600))
First part being the signal * window = windowed signal… And what I get is this..
Why is this so different.. What am I doing wrong?
As I see it you have two errors in your expression. First you miss parenthesis around the window function and second you have the wrong period in the cos term. Try
w = (sin(0.9*pi*t) + sin(0.42*pi*t)).*(0.54 – 0.46*( cos(2*pi*t/t(end))));