Matlab FFT用于高斯函数 [英] Matlab FFT for gaussian function

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

问题描述

我正在尝试通过使用matlab的fft获得gaussian curve.问题是,在一种情况下,我尝试通过除以F=dt.*F./exp(-1i.*nu.*T/2)来降低噪声的尝试无效(img 1),而在第二种情况下,如果我尝试获取fft结果的绝对值,则图表中的缩放比例不正确(img 2) ).

I am trying to obtain gaussian curve by using matlab's fft. The problem is that in one case my attemp to reduce noise by dividing F=dt.*F./exp(-1i.*nu.*T/2) is not working (img 1) and in the second case if I am trying to take absolute value of fft result's I dont have decent scale in graph (img 2).

N=512;
T=10;
dt=T/(N-1);
t=linspace(-5,5,N);
f=exp(-t.^2);
F=fft(f);

F1=F(1:N/2+1);
F2=F(N/2+1:N);
F=[F2,F1];

dnu=(N-1)/(N*T);
nuNyq=1/(2*dt);
nu=-nuNyq+dnu*(0:N);
F=dt.*F;
%F=dt.*F./exp(-1i.*nu.*T/2);


y=linspace(-5,5,N);
F2=pi.^(1/2).*exp(-y.^2/4);

hold on
plot(y,F2); 
%plot(nu,real(F),'r');
plot(nu,abs(F),'r');
legend('analiticFT','FFT')
xlim([-5 5])
hold off

img 1

img2

推荐答案

似乎傅里叶变换在公式中的缩放比例不太正确.根据 Wikipedia上的傅立叶变换表,连续时间的变换域信号

It seems the scaling in your formula for the analytic Fourier Transform is not quite correct. According to this Fourier Transform table on Wikipedia, the transform of the continuous time-domain signal

在您的情况下为a=1.相应地,您应该比较时域信号的FFT

where in your case a=1. Correspondingly, you should compare the FFT of the time domain signal

t=linspace(-5,5,N);
f=exp(-t.^2);

使用傅立叶分析

F2 = sqrt(pi)*exp(-(pi*y).^2);

因此,绘制与以下内容的比较:

So, plotting the comparison with:

hold off;
plot(y,F2); 
hold on;
plot(nu,abs(F),'r');
legend('analiticFT','FFT')
xlim([-5 5])

产量:

现在我们已经建立了适当的比较基础,我们可以看看为什么您会在img 1中获得振荡.简而言之,您生成的参考高斯脉冲f=exp(-t.^2);t=0处有一个峰值.相应的零" 离散时间自然是数组中的第一个索引(索引1).但是,在您的阵列中,该峰值出现在索引N/2处.在 Shift定理下,这会在频域中引起一个附加的exp(-pi*j*k)项,对您所看到的振荡负责.要解决此问题,您应使用ifftshift:

Now that we have establish a proper basis for comparison, we can look at why you are getting the oscillations in img 1. Simply put, the reference Gaussian pulse f=exp(-t.^2); you have generated has a peak at t=0. The corresponding "zero" discrete time instant is naturally the first index in the array (index 1). However in your array, this peak appears at index N/2. Under the Shift theorem, this causes an additional exp(-pi*j*k) term in the frequency domain, responsible for the oscillations you are seeing. To fix this, you should shift back your Gaussian pulse with ifftshift:

F=fftshift(fft(ifftshift(f)));

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

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