%
% Analysis Using FFT
%
clear
n=128;
T=5;
dt=T/n;
f0=6.2;
f1=10;
y=sin(2*pi*f0*(1:n)*dt)+2*sin(2*pi*f1*(1:n)*dt);
% y=exp(-0*(1:n)*dt).*sin(2*pi*f0*(1:n)*dt);
Y=fft(y,n);
n2=n/2;
Power=Y.*conj(Y)/n^2;
f=(0:n2)/(n2*2*dt);
stem(f,2*Power(1:n2+1))
xlabel('Frequency')
ylabel('Power')
title('Periodogram')
figure(2)
subplot(2,1,1)
stem(f,real(Y(1:n2+1)))
xlabel('Frequency')
ylabel('Amplitude')
title('A')
subplot(2,1,2)
stem(f,imag(Y(1:n2+1)))
xlabel('Frequency')
ylabel('Amplitude')
title('B')
figure(1)