DSPRelated.com
Code

Continuous Time Fourier Series of Cosine signal

Senthilkumar March 21, 2011 Coded in Scilab

This program is used to calculate Continuous Time Fourier Series Spectral Coefficients of a periodic Cosine signal

//Continuous Time Fourier Series Spectral Coefficients of 
//a periodic Cosine signal x(t) = cos(Wot)
clear;
close;
clc;
t = 0:0.01:1;
T = 1;
Wo = 2*%pi/T;
xt = cos(Wo*t);
for k =0:5
  C(k+1,:) = exp(-sqrt(-1)*Wo*t.*k);
  a(k+1) = xt*C(k+1,:)'/length(t); //fourier series is done
  if(abs(a(k+1))<=0.01) 
    a(k+1)=0;
  end
end
a =a';
ak = [a($:-1:1),a(2:$)];
disp(ak,'Continuous Time Fourier Series Coefficients are:')
//Result
//Continuous Time Fourier Series Coefficients are:   
// column  1 to 11
// 0 0 0 0 0.5049505+1.010D-18i  0  0.5049505-1.010D-18i  0  0 0 0