How to calculate and sketch the Fourier Transform of a gaussian function?

8 ビュー (過去 30 日間)
Nathan
Nathan 2022 年 9 月 22 日
コメント済み: Paul 2022 年 9 月 22 日
Hello,
I have the following function:
(exp(-pi.*x.^2) + 0.25.*exp((-pi.*x.^2)/16))
Unrecognized function or variable 'x'.
I'm trying to calculate and sketch its fourier transform version.
This is what I tried but it seems wrong.
x_fit_func = @(x) (exp(-pi.*x.^2) + 0.25.*exp((-pi.*x.^2)/16));
x = linspace(-10, 10, 50);
x_F = fft(x_fit_func(x))/numel(x);
Fs = 1/mean(diff(x));
Fn = Fs/2;
Fv = linspace(-1, 1, numel(x_F))*Fn;
Iv = 1:numel(Fv);
figure
plot(Fv, fftshift(abs(x_F)))
grid

採用された回答

Paul
Paul 2022 年 9 月 22 日
Hi Steven
What doesn't seem correct? The only issue I see is the calculation of Fv, modified below.
x_fit_func = @(x) (exp(-pi.*x.^2) + 0.25.*exp((-pi.*x.^2)/16));
x = linspace(-10, 10, 50);
x_F = fft(x_fit_func(x))/numel(x);
Fs = 1/mean(diff(x));
Fv = (-25:24)/50*Fs; % frequency vector for N = 50 (N is even)
figure
plot(Fv, fftshift(abs(x_F)))
grid
  2 件のコメント
Nathan
Nathan 2022 年 9 月 22 日
I'm still new to matlab and read this code from another forum, which is why I'm not so sure if the impulse response looks correct. I initially tried fft(f_x) where f_x is my function in time domain but the graph came out looking very weird. Do you mind explain your code briefly? Thank you!
Paul
Paul 2022 年 9 月 22 日
I'm not sure how impulse response has entered the dicussion or what fft(f_x) means without seeing a definition of f_x.
My code is your code. All I did was correct the calculation of the Fv vector. Is that the part that needs further explanation?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDiscrete Fourier and Cosine Transforms についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by