1. Use matlab to generate a sinsoid signal r(t)=exp(j.*2.*pi.*fc.*t), where fc =
ID: 3751861 • Letter: 1
Question
1. Use matlab to generate a sinsoid signal r(t)=exp(j.*2.*pi.*fc.*t), where fc = 200e3, and set time to be t=0.1e-6: 0.1e-6:20e-6.
1) Use command fft(x, N) to plot FFT of the sinsoid signal using 200 points FFT transform, i.e. (N=200)
2) Plot FFT of the sinsoid signal using 2000 points FFT transform, i.e. (N=2000).
3) Change t to t=0.1e-6: 0.1e-6:200e-6, and do 2000 points FFT transform.
4) Compare the differences between 1), 2), and 3).
Below is my code so far. I am stuck translating the frequency for the N point FFT to plot the figures. once I have that I can finalize the plotting myself.
fc = 200*10^3;
t1 = 0.1*10^-6 : 0.1*10^-6 : 20*10^-6;
t2 = 0.1*10^-6 : 0.1*10^-6 : 200*10^-6;
f1 = (0:200/2-1)*fc/200;
f2 = (0:2000/2-1)*fc/2000;
rt1 = exp(j.*2.*pi.*fc.*t1);
rt2 = exp(j.*2.*pi.*fc.*t2);
rt1FFT200 = fft(rt1, 200);
rt1FFT200 = rt1FFT200(1:200/2);
mrt1FFT200 = abs(rt1FFT200);
rt1FFT2000 = fft(rt1, 2000);
rt2FFT2000 = fft(rt2, 2000);
figure
subplot(3,1,1)
plot (f1, mrt1FFT200)
title('Part 1 N = 200')
subplot(3,1,2)
plot (f2, rt1FFT2000)
title('Part 2 N = 2000')
subplot(3,1,2)
plot (f2, rt2FFT2000)
title('Part 3 N = 2000')
Explanation / Answer
Answer:
y=fft(data); %data is the signal
PS=(abs(y).^2);
N=length(data);
fc=2000;
freq=(1:N/2)*fs/N;
plot(freq,PS((1:N/2)));
xlabel('Frequency (Hz)');
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.