Understanding the Matlab FFT Example: Sampling Frequency, Nyquist Frequency, and Frequency Axis Interpretation

Dec 07, 2025 · Programming · 17 views · 7.8

Keywords: Matlab | FFT | Nyquist frequency

Abstract: This article provides an in-depth analysis of key concepts in the Matlab FFT example, focusing on why the frequency axis ends at 500Hz, the importance of the Nyquist frequency, and the relationship between FFT output and frequency mapping. Using a signal example with a sampling frequency of 1000Hz, it explains frequency folding phenomena, single-sided spectrum plotting principles, and clarifies common misconceptions about FFT return values. The article combines code examples and theoretical explanations to offer a clear guide for beginners.

Introduction

The Fast Fourier Transform (FFT) is a core tool in digital signal processing, and Matlab provides a powerful implementation. However, beginners often encounter confusion regarding the frequency axis range and FFT output when using the Matlab FFT example. This article delves into these key issues based on the official Matlab example.

Sampling Frequency and Nyquist Frequency

In the Matlab example, the sampling frequency Fs = 1000 Hz indicates 1000 data points collected per second. According to the Nyquist-Shannon sampling theorem, the highest frequency that can be reconstructed without distortion is half the sampling frequency, i.e., the Nyquist frequency Fs/2 = 500 Hz. Therefore, the frequency axis ending at 500Hz is not due to ignoring higher frequencies but a physical limitation: frequencies above 500Hz undergo aliasing and fold back into the 0-500Hz range.

Frequency Axis Generation Principle

The frequency axis in the example is generated by the following code:

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

Here, linspace(0,1,NFFT/2+1) creates a uniformly spaced vector from 0 to 1, which is multiplied by Fs/2 to map to the 0-500Hz range. Due to the symmetry of the FFT output, only the single-sided spectrum (first NFFT/2+1 points) is plotted to represent the entire frequency information.

FFT Output and Frequency Mapping

Matlab's fft function returns a complex amplitude vector without direct frequency information. Frequency values must be calculated based on the sampling frequency and signal length. In the example:

Y = fft(y,NFFT)/L;

After normalization, abs(Y) represents the amplitude spectrum. The single-sided amplitude spectrum is plotted via plot(f,2*abs(Y(1:NFFT/2+1))), where the factor 2 compensates for the discarded symmetric part.

Aliasing and Frequency Folding

If the signal contains components above the Nyquist frequency, aliasing occurs in the FFT results. For instance, a 600Hz signal sampled at 1000Hz will fold and appear as 400Hz in the spectrum. This explains why the frequency axis is limited to 0-500Hz: higher frequencies are distorted during sampling, and the FFT cannot distinguish them.

Practical Application Recommendations

1. Use an anti-aliasing filter before sampling to limit signal bandwidth below Fs/2.
2. Choose FFT length as a power of two (e.g., using nextpow2) to improve computational efficiency.
3. For real signals, leverage symmetry to plot single-sided spectra for simplified analysis.

Conclusion

The key to understanding the Matlab FFT example lies in mastering the sampling theorem and frequency mapping. The frequency axis ends at 500Hz due to the Nyquist frequency, and the FFT returns amplitude values that must be interpreted in conjunction with the calculated frequency axis. Proper application of these concepts enables effective analysis of signal frequency domain characteristics.

Copyright Notice: All rights in this article are reserved by the operators of DevGex. Reasonable sharing and citation are welcome; any reproduction, excerpting, or re-publication without prior permission is prohibited.