function [X_AXIS, FFT_OUTPUT] = fft_analysis(x,T) % %[X_AXIS, FFT_OUTPUT] = FFT_ANALYSIS(x,T) % %This function gives the fft of a time domain signal. %x is the time domain signal and T is the sampling period. %If the sampling period isn't specified, it is set to 125 us (1/8kHz) %The input x must be a column matrix in order for the x-axis to be %computed correctly. %This function computes the fft; centers the spectral %information around 0 Hz; and computes the x-axis frequency %points for each fft output sample. This function returns %the fft centered output and the x-axis. if nargin == 1 T = 1/8e3; end FFT_OUTPUT = fft(x); %compute the FFT of x FFT_OUTPUT = fftshift(FFT_OUTPUT); %center the spectrum of the FFT output X_AXIS = -(size(FFT_OUTPUT,2)/2):(size(FFT_OUTPUT,2)/2)-1; %set axis to -NUM_OF_SAMPLES/2 < SAMPLE < (NUM_OF_SAMPLES/2)-1 X_AXIS = X_AXIS*(1/(size(FFT_OUTPUT,2)*T)); %set frequency axis to -Fs/2 < F < (Fs/2)-1 axis (Hz) = K(1/NT); axis (radians) = K(2pi/NT)