Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In Matlab. Generate a 512 point waveform consisting of two sinusoids at 200 and

ID: 3796488 • Letter: I

Question

In Matlab. Generate a 512 point waveform consisting of two sinusoids at 200 and 400 Hz. Assume a sampling frequency of 1 kHz. Also generate another waveform containing frequencies at 200 and 900 Hz. Take the Fourier Transform of both waveforms and plot the magnitude of the spectrum up to fs/2. Plot the 2 spectra superimposed, but in different colors to highlight the additional peak at 100 Hz due to aliasing.   You can use the equation   x=sin(2*pi*f1*t) + sin(2*pi*f2*t), where f1 is 200 Hz for both signals and f2 is 400 for one waveform and 900 for the other waveform.

Explanation / Answer

clear all; close all;

N=512;

t=(1:N)/N;

fs=1000;

f=(1:N)*fs/N;

x= sin(2*pi*200*t) + sin(2*pi*400*t);

y= sin(2*pi*200*t) + sin(2*pi*900*t);

for n = 1:20

a(n) = (2/N)*sum(x.*(cos(2*pi*n*t)))

b(n) = (2/N)*sum(x.*(sin(2*pi*n*t)))

c(n) = sqrt(a(n).^2+b(n).^2)

theta(n) =-(360/(2*pi))*atan(b(n)./a(n));

end

plot(f(1:20),c(1:20),'rd');

disp([a(1:4),b(1:4),c(1:4),theta(1:4)])

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote