%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%sum_cos_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] = sum_cos_fft(A,Wo,N,samples)
%Inputs
%A = Amplitude vector
%Wo = Omega vector
%samples = # of samples between 0 - 2pi,  must be a power of 2

%Example input, 
%Amp_Vector = [.3,.34,.8,.9]';
%Wo=[.76*pi,.98*pi,.23*pi,.75*pi]';
%sin_fft(Amp_Vector,Wo_Vector,N,1024)

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

n=[0:N-1]';
vector_size=length(A);
i=1;
z=0;

while i <= vector_size
x = A(i)*cos(n*Wo(i));
z = z + x;
i=i+1;
end

Xspect = fft(z,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, Using Rectangular Window'),ylabel('Amplitude');
