当前位置:网站首页>What's the use of fftshift? Why does matlab need fftshift after FFT?
What's the use of fftshift? Why does matlab need fftshift after FFT?
2022-07-18 07:54:00 【Xuan yanru Liu】
The article is only for personal understanding , Please correct the shortcomings
In use MATLAB do FFT When analyzing signals , Why do you sometimes need to fftshift, Sometimes you don't need , I've done it carefully today , Make a summary note .
First ,fftshift Usage of :
Y = fftshift(X)
Y = fftshift(X,dim)
effect : Swap the left and right halves of the row vector .
stay FFT The role of Li : By moving the zero frequency component to the center of the array .
Why are you in FFT And then we use fftshift Well ?
I think this problem can be explained from the perspective of sampling law . Take baseband real signal as an example , We all know that the time domain is based on f s f_s fs Sampling is in the frequency domain f s f_s fs Translational continuation , Because the spectrum of the sampled signal will be in f s / 2 f_s/2 fs/2 Produce aliasing , So the real signal sampling rate f s / 2 f_s/2 fs/2 The bandwidth should be greater than or equal to , namely f s ≥ 2 B f_s≥2B fs≥2B, Here's the picture .
MATLAB Doing... On the sequence FFT When , It is equivalent to taking the spectrum [ 0 , f s ] [0,f_s] [0,fs] Part of , Because the spectrum is based on f s f_s fs Periodic extension , therefore [ f s / 2 , f s ] [f_s/2,f_s] [fs/2,fs] Part of the spectrum and [ − f s / 2 , 0 ] [-f_s/2,0] [−fs/2,0] Part of the same , If you want to see [ − f s , f s ] [-f_s,f_s] [−fs,fs] part ( The red box part of the picture above ), It needs to be done fftshift, Move the zero frequency component to the middle of the sequence , Here's an example .
close all; clear; clc;
fs = 300; % The sampling rate is greater than 200
t = 0:1/fs:1; % Define sampling points
s = sin(2*pi*100*t)+cos(2*pi*40*t); % The sampled signal sequence
%--------- see [0,fs] The spectrum of ---------
F1 = fft(s); %fft
f1 = linspace(0,fs,length(t)); % Spectrum horizontal axis
subplot(211);plot(f1,abs(F1));xlabel('f');ylabel(' Range ');title(' see [0,fs]');
%--------- see [-fs/2,fs/2] The spectrum of ---------
F2 = fftshift(fft(s)); %fft
f2 = linspace(0,fs,length(t))-fs/2; % Spectrum horizontal axis
subplot(212);plot(f2,abs(F2));xlabel('f');ylabel(' Range ');title(' see [-fs/2,fs/2]');
give the result as follows :
therefore ,fftshift To see [ − f s / 2 , f s / 2 ] [-f_s/2,f_s/2] [−fs/2,fs/2] Operation required for partial spectrum , If you just look at [ 0 , f s ] [0,f_s] [0,fs] The spectrum of , Not really .
The above is only the case of real sequences , However, we often use complex sequences in simulation experiments , Now let's talk about complex sequences .
Complex sequences have no negative frequencies , As long as the sampling rate is greater than the bandwidth , According to the above explanation, it is easy to understand this ,
The picture above shows , as long as f s ≥ B f_s≥B fs≥B, The spectrum will not be aliased . So I won't go to see [ − f s / 2 , f s / 2 ] [-f_s/2,f_s/2] [−fs/2,fs/2] The spectrum of , Will not use fftshift 了 .
close all; clear; clc;
fs = 300; % The sampling rate is greater than 100
t = 0:1/fs:1; % Define sampling points
s = exp(1j*2*pi*100*t)+exp(1j*2*pi*40*t); % The sampled signal sequence
%--------- see [0,fs] The spectrum of ---------
F1 = fft(s); %fft
f1 = linspace(0,fs,length(t)); % Spectrum horizontal axis
plot(f1,abs(F1));xlabel('f');ylabel(' Range ');title(' see [0,fs]');
%--------- see [-fs/2,fs/2] The spectrum of ---------
% There is no negative frequency , It's meaningless here
% F2 = fftshift(fft(s)); %fft
% f2 = linspace(0,fs,length(t))-fs/2; % Spectrum horizontal axis
% subplot(212);plot(f2,abs(F2));xlabel('f');ylabel(' Range ');title(' see [-fs/2,fs/2]');

边栏推荐
- Analysis of risks related to cloud infrastructure and corresponding defense measures
- fftshift有什么用?MATLAB做FFT后为什么还要fftshift?
- Pytorch分布式训练
- 云平台与基础架构中需要考虑哪些安全风险
- C language · prefix tree implementation
- 美团一面:为什么线程崩溃崩溃不会导致 JVM 崩溃?
- My first anniversary of creation
- C#小技巧 获取枚举所有枚举值
- Redis distributed lock: what have you experienced from Xiaobai to Dashen?
- 394.字符串解码·栈
猜你喜欢

Allure测试报告怎么设置

安徽大学标志性建筑

MySQL 为什么临时表可以重名 ?

一家火锅店,凑了三个IPO

进阶测试人必看:自动化测试入门基础知识

Advanced testers must see: basic knowledge of automated testing

2022 China mobile maker marathon Internet of things special competition kicks off

337. Looting · dynamic planning

二叉树(BinaryTree)和堆(Heap)的知识点整理

Matlab:数据集读取 imageDatastore() 的用法
随机推荐
秋招拿了6offer,总结了20多类1100道面试题含答案解析
Supplementary cases and knowledge points in the first six chapters (I)
LDAP介绍
李沐动手学深度学习V2-目标检测数据集
One question per day · 735 Planetary collision · stack simulation
二叉树(BinaryTree)和堆(Heap)的知识点整理
Allure测试报告怎么设置
Redhat7.9 configure Yum source
安徽大学店铺
AMD Ryzen 5 7600X 6核心和4.4GHz 'Zen 4 ' CPU现身跑分数据库
Which futures account is the best in 2022? Is the account opening fee the lowest? Safest?
根据经纬度计算两点之间的距离
每日一题·735.行星碰撞·栈模拟
(open source project) abattoir unity game
openGauss 联合产业界创新,共建开源数据库根社区
Advanced testers must see: basic knowledge of automated testing
What security risks need to be considered in cloud platforms and infrastructure
Several things I want to understand about being laid off at the age of 30
每日一题·1252.奇数值单元格的数目·模拟优化
Meituan's one-sided experience and detailed answers