
% set time domain
N = 128;
T = (0:(N-1))/N;
T = T';            % make a column vector

% set signal
X = 1+ 0.5*cos(5*2*pi*T)- 0.25*sin(10*2*pi*T);

% set wave forms
C0 = cos(0*2*pi*T);
S0 = sin(0*2*pi*T);
E0 = exp(0*2*pi*i*T);
C5 = cos(5*2*pi*T);
S5 = sin(5*2*pi*T);
E5 = exp(5*2*pi*i*T);
C10 = cos(10*2*pi*T);
S10 = sin(10*2*pi*T);
E10 = exp(10*2*pi*i*T);

subplot(2,1,1)
plot(T,X,'k',T,C0,'b',T,X.*C0,'r',T,0,'k');
axis([0,1,-2,2])
subplot(2,1,2)
plot(T,X,'k',T,S0,'b',T,X.*S0,'r',T,0,'k');
axis([0,1,-2,2])
a0 = C0'*X/N
b0 = S0'*X/N
c0 = E0'*X/N
disp('press a key')
pause

subplot(2,1,1)
plot(T,X,'k',T,C5,'b',T,X.*C5,'r',T,0,'k');
axis([0,1,-2,2])
subplot(2,1,2)
plot(T,X,'k',T,S5,'b',T,X.*S5,'r',T,0,'k');
a5 = C5'*X/N
b5 = S5'*X/N
c5 = E5'*X/N
disp('press a key')
pause

subplot(2,1,1)
plot(T,X,'k',T,C10,'b',T,X.*C10,'r',T,0,'k');
axis([0,1,-2,2])
subplot(2,1,2)
plot(T,X,'k',T,S10,'b',T,X.*S10,'r',T,0,'k');
axis([0,1,-2,2])
a10 = C10'*X/N
b10 = S10'*X/N
c10 = E10'*X/N
