了解Matlab FFT示例 [英] Understanding Matlab FFT example

查看:107
本文介绍了了解Matlab FFT示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Matlab和FFT的新手,并且想了解 Matlab FFT示例. 现在,我有两个主要问题:

I am new to matlab and FFT and want to understand the Matlab FFT example. For now I have two main questions:

1)为什么x轴(频率)以500结尾?我怎么知道没有更多的频率,或者只是被忽略了?

1) Why does the x-axis (frequency) end at 500? How do I know that there aren't more frequencies or are they just ignored?

2)我怎么知道频率在0到500之间? FFT是否不应该告诉我频率在哪个限制内? FFT是否仅返回幅度值而没有频率?

2) How do I know the frequencies are between 0 and 500? Shouldn't the FFT tell me, in which limits the frequencies are? Does the FFT only return the amplitude value without the frequency?

谢谢您的提示!

考虑以1000 Hz采样的数据.形成一个包含振幅为0.7的50 Hz正弦波和振幅为1的120 Hz正弦波的信号,并以零均值随机噪声对其进行破坏:

Consider data sampled at 1000 Hz. Form a signal containing a 50 Hz sinusoid of amplitude 0.7 and 120 Hz sinusoid of amplitude 1 and corrupt it with some zero-mean random noise:

Fs = 1000;                    % Sampling frequency
T = 1/Fs;                     % Sample time
L = 1000;                     % Length of signal
t = (0:L-1)*T;                % Time vector
% Sum of a 50 Hz sinusoid and a 120 Hz sinusoid
x = 0.7*sin(2*pi*50*t) + sin(2*pi*120*t); 
y = x + 2*randn(size(t));     % Sinusoids plus noise
plot(Fs*t(1:50),y(1:50))
title('Signal Corrupted with Zero-Mean Random Noise')
xlabel('time (milliseconds)')

转换到频域,通过进行快速傅立叶变换(FFT),可以找到噪声信号y的离散傅立叶变换:

Converting to the frequency domain, the discrete Fourier transform of the noisy signal y is found by taking the fast Fourier transform (FFT):

NFFT = 2^nextpow2(L); % Next power of 2 from length of y
Y = fft(y,NFFT)/L;
f = Fs/2*linspace(0,1,NFFT/2+1);

% Plot single-sided amplitude spectrum.
plot(f,2*abs(Y(1:NFFT/2+1))) 
title('Single-Sided Amplitude Spectrum of y(t)')
xlabel('Frequency (Hz)')
ylabel('|Y(f)|')

推荐答案

1)为什么x轴(频率)以500结尾?我怎么知道没有更多的频率,或者只是被忽略了?

1) Why does the x-axis (frequency) end at 500? How do I know that there aren't more frequencies or are they just ignored?

它以500Hz结束,因为它是在1000Hz采样时信号的奈奎斯特频率.在Mathworks示例中查看以下行:

It ends at 500Hz because that is the Nyquist frequency of the signal when sampled at 1000Hz. Look at this line in the Mathworks example:

f = Fs/2*linspace(0,1,NFFT/2+1);

第二个图的频率轴从0到 Fs/2,或者是采样频率的一半. 奈奎斯特频率始终是采样频率的一半,因为在此之上,会发生混叠:

The frequency axis of the second plot goes from 0 to Fs/2, or half the sampling frequency. The Nyquist frequency is always half the sampling frequency, because above that, aliasing occurs:

信号会折叠"回去,并出现为500Hz或以下的某个频率.

The signal would "fold" back on itself, and appear to be some frequency at or below 500Hz.

2)我怎么知道频率在0到500之间? FFT是否不应该告诉我频率在哪个限制内?

2) How do I know the frequencies are between 0 and 500? Shouldn't the FFT tell me, in which limits the frequencies are?

由于上述折叠"(奈奎斯特频率也通常称为折叠频率"),因此500Hz以上的频率在物理上不可能出现在FFT中.较高的频率将折回"并显示为较低的频率.

Due to "folding" described above (the Nyquist frequency is also commonly known as the "folding frequency"), it is physically impossible for frequencies above 500Hz to appear in the FFT; higher frequencies will "fold" back and appear as lower frequencies.

FFT是否仅返回幅度值而没有频率?

Does the FFT only return the amplitude value without the frequency?

是的,MATLAB FFT函数仅返回一个振幅向量.但是,它们映射到您传递给它的频率点.

Yes, the MATLAB FFT function only returns one vector of amplitudes. However, they map to the frequency points you pass to it.

让我知道需要澄清什么,以便我进一步帮助您.

Let me know what needs clarification so I can help you further.

这篇关于了解Matlab FFT示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆