Last active
August 29, 2015 09:51
-
-
Save mick001/c1ab7747d94be78ba1c6 to your computer and use it in GitHub Desktop.
Calculate Fourier transform of a gaussian using Matlab. Full article at: http://www.firsttimeprogrammer.blogspot.com/2015/05/calculate-fourier-transform-of-gaussian.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Fourier transform calculation | |
%------------------------------------------------------- | |
% Declare symbols to use | |
syms x t; | |
% Parameters of the transform | |
a = 300; %scaling | |
b = 0; %shifting | |
c = 0; %smoothing | |
% Function to transform | |
u = exp(-(a*t-b)^2) * exp(1i*c*t); | |
% Transform of u | |
uHat = fourier(u,t,x); | |
% Printing u and u hat | |
simplify(uHat); | |
pretty(u) | |
pretty(uHat) | |
% Plotting | |
x_axis = linspace(-15,15,500); | |
figure; | |
plot(x_axis,abs(subs(uHat,x_axis)),x_axis,abs(subs(u,x_axis))); | |
xlabel('x');ylabel('y'); | |
title('Function and its Fourier Transform'); | |
legend('Fourier transform','function'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment