function [Xmag,Xphase,df,frq] = ece300_fft(x,dt)
%
% Computes FFT of input vector, including unwrapping the phase vector
%   BAF  Fall 2002
%
% usage:  [M,P,df,frq]=baf_fft(x,dt)
%       x = function for which FFT is calculated (must have 2^m samples)
%       dt = time spacing between samples of the function x
%       Xmag = vector containing magnitude of the FFT spectral components
%       Xphase = vector containing phase of FFT spectral components
%       df = frequency spacing between FFT samples
%       frq = vector containing frequency values for the Xmag and Xphase vectors
%
N=length(x);
df=1/N/dt;
% compute FFT
X1=1/N*fft(x);
% extract the positive freq components to create a single sided spectrum
X=X1(1:floor(N/2));
% compute mag and phase vector, with phase unwrapping
Xmag=2*abs(X);
Xphase=unwrap(angle(X));
% generate frequency vector associated with FFT vectors
frq=linspace(0, (floor(N/2)-1)*df, floor(N/2));