필터 지우기
필터 지우기

Plotting |X(m)|, Xmagnitude of signal x(t)

조회 수: 4 (최근 30일)
Jorge Cantu
Jorge Cantu 2015년 5월 6일
댓글: Jorge Cantu 2015년 5월 6일
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)');

답변 (1개)

Walter Roberson
Walter Roberson 2015년 5월 6일
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.
  댓글 수: 1
Jorge Cantu
Jorge Cantu 2015년 5월 6일
I added my plot above, I forgot to do that the first time, but have a look.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Spectral Measurements에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by