Example Fourier Transforms

The script plots either the real part or the imaginary part of the transform, so it works for functions that are either even or odd (not mixed).

We know the answer: (sinc^2)

fourier(@tri);
maximum real value 1
maximum imag value 5.45354e-017

We know the answer here also: tri

test = @(x) sinc(x).^2;
fourier(test);
maximum real value 0.993669
maximum imag value 9.71445e-017

self-transforming function

fourier(@gaus);
maximum real value 1
maximum imag value 9.36751e-017

even function (pair of delta functions along real axis)

fourier(@(x) cos(2*pi*x));
maximum real value 16
maximum imag value 2.22045e-016

odd function (delta functions along imaginary axis

fourier(@(x) sin(2*pi*x));
maximum real value 3.19768e-016
maximum imag value 16