Plotting |X(m)|, Xmagnitude of signal x(t)
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens

Hi everyone, I am trying to plot the frequency spectrum of the magnitude for the following signal x(t)=3+5sin(2*pi*4000*t)+2sin(2*pi*6000*t). However, the plot above does not look right. Can someone review my work and see if this is correct?
Here is the task, and the code.
(b) Obtain |X(m)|.
(c) Plot the one-sided spectrum with redundancy, |X(m)| vs frequency.
Code:
close all;
clear all;
t = 0:10:1000; % Time vector
fs = 16000;
xt=3+5*sin(2*pi*4000*t)+2*sin(2*pi*6000*t);
N = 7;
y = abs(fft(xt,N)); % Compute DFT of x
fax_bins = [0 : N-1]; %N is the number of samples in the signal
f_hertz = fax_bins*fs/N;
plot(f_hertz, y)
xlabel('Frequency (Bins)')
ylabel('Magnitude');
title('Double-sided Magnitude spectrum (bins)');
Réponses (1)
Walter Roberson
le 6 Mai 2015
When you use sin(2*pi*t) then each change of 1 in t corresponds to a full cycle of the sine wave. When you use sin(2*pi*4000*t) then each change in 1 in t corresponds to 4000 full cycles of the sine wave.
All of your t are integral, 0, 10, 20, and so on, so you are plotting at points corresponding to 0 full periods of sine, 10*4000 full periods of sine, 20*4000 full periods of sine, and so on. And each of those is of course going to come out exactly the same to within round-off error: all 0 to within round-off. Effectively the "xt" you calculate will be constant to within round-off error.
You need to figure out what you want "10" to represent for t. 10 seconds? If so then you get the problem I described, where you are always sampling at the same point on the wave.
Voir également
Catégories
En savoir plus sur Spectral Measurements dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!