%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%sin_fft this function will take     %
%and plot the fft of a cos function  %
%for a rectangular window.  W, An and%
%# of samples will have to be entered%
%as well at the phase shift.         %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function [Xspect, w] = cos_fft(A,Wo,N,samples)
%Inputs
%A = Amplitude
%Wo = Omega
%N = Window Size
%samples = # of samples between 0 - 2pi,  must be a power of 2
%Example input, sin_fft(.7,.8*pi,100,1024)

%Outputs
%Xspect = Spectrum Vector
%w = output w vector

n=[0:N-1]';
x = A*cos(n*Wo);
Xspect = fft(x,samples);
w=[0:samples-1]'*2*pi/samples;
figure,plot(w(1:samples/2)/pi,abs(Xspect(1:samples/2)));
xlabel('frequency(*\pi),\omega'), title('Spectral Analysis, Using Rectangular Window'),ylabel('Amplitude');
figure,stem(w(1:samples/2)/pi,abs(Xspect(1:samples/2)));
xlabel('frequency(*\pi),\omega'), title('Spectral Analysis'),ylabel('Amplitude');