in discussion Forum Discussion / General Discussions » MATLAB .m files

myfouriertransform.m

function[faxis,omegaaxis,y]=myfouriertransform(x,fs,N)

% This is a function that returns the fourier transform

% of a signal x which has been sampled at a sampling frequency of fs Hz

% faxis - a vector which shows the freq in Hz where the FT is computed

% omegaaxis - a vector with freq in rad/s where the FT is computed

y = (1/fs)*fftshift(fft(x,N));

Omegaaxis = (-pi:2*pi/N:pi-pi/N);

omegaaxis = fs*Omegaaxis;

faxis = omegaaxis/(2*pi);

myinversefouriertransform.m

function[taxis,y]=myinversefouriertransform(X,fs,N)

y = fs*ifft(ifftshift(X),N);

taxis = [0:1:N-1]*(1/fs);