Reproduced Summary and analysis of FFT and Fftshift command in MATLAB

Source: Internet
Author: User
Tags sin

Http://blog.sina.com.cn/s/blog_68f3a4510100qvp1.html

NOTE: Reprint please indicate source--by author.

We know that Fourier analysis is a very important technology in signal processing, MATLAB provides a powerful signal processing capability, but there are some details that need our attention.

The starting time of the signal F (t) is T_start, the terminating time is t_end, the sampling period is t_s, the duration of the signal can be calculated Duration to T_end–t_start, the signal discretization caused by the sampling number N = duration/t_s + 1;

According to the conclusion of Fourier analysis, we know that sampling in time domain will cause the periodicity of frequency domain, the period is sampling frequency f_s (the famous Shannon sampling theorem is based on this).

So, after the FFT function of MATLAB processing, get the data of the horizontal axis is 0:f_s/(N-1): f_s. The relevant code looks like this:

%matlab FFT test Code

t_s = 0.01;
T_start = 0.5; T_end = 5;
t = t_start:t_s:t_end;
y = 0.5*sin (2*pi*15*t) +2*sin (2*pi*40*t);
Y_f = FFT (y);

Subplot (3,1,1);
Plot (t,y); Title (' original signal ');

Duration = T_end-t_start;
sampling_points = duration/t_s + 1;

f_s = 1/t_s;
f_x = 0:f_s/(sampling_points-1): f_s;

Subplot (3,1,2);
Plot (F_x,abs (Y_f)); Title (' FFT transform ');

Subplot (3,1,3);
Plot (F_x-f_s/2,abs (Fftshift (Y_f))); Title (' Shift FFT transform ');

That is, if we do not use Fftshift, its transformation of the horizontal axis is 0:f_s/(N-1): f_s, if you use the Fftshift command, the 0 frequency component will be moved to the coordinate center, which is the meaning of the Help Center in MATLAB: the FFT coordinates are processed. In fact, due to the periodicity of the spectrum, it is reasonable and acceptable for us to do so.

Please pay special attention to the difference of the horizontal axis. In addition, according to the characteristics of the function, the spectrum should be only in the 15hz,40hz peak, but the FFT transformation in the 60Hz, and 85Hz at the same peak, should be able to be interpreted from the FFT calculation process.

In fact, if we use 15hz,60hz to test the FFT transformation, that is, y = 0.5*sin (2*pi*15*t) +2*sin (2*pi*60*t); The image is as follows, without any change.

This phenomenon reminds us that frequencies within f_s, that is, 0<f<f_s,f and f_s–f, are likely to be the frequency spectra of test signals, which leads us to ambiguity. And as can be seen from the third sub-graph, this time the fftshift will bring us the wrong guidance, that is, if we try to sample FFT or Fftshift to analyze the frequency spectrum of the signal is not so reliable, The FFT spectral line of MATLAB is not the corresponding mapping relationship with the actual frequency of the signal one by one. This is certainly not the result we expect to see, so when it comes to the actual analysis of the signal, additional attention is needed on this issue.

In fact, this also indirectly proves the rationality of the Nyquist sampling theorem: The sampling frequency is higher than the cutoff frequency of twice times, the above processing we use the sampling frequency is 100Hz, so when the cutoff frequency of more than 50Hz, there will be aliasing effect, the special case as shown: exactly the same. Therefore, this also tells us to correctly display the spectrum, the need to carefully consider the sampling frequency and cutoff frequency relationship, if too small, it is possible to overlap, if too large, the calculation is too expensive.

Reproduced Summary and analysis of FFT and Fftshift command in MATLAB

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.