EXPERIMENT - 10


AIM

To do Spectral Analysis of a Sinusoidal signal and, plot it's energy and frequency spectrum.

THEORY

Spectral analysis or Spectrum analysis is analysis in terms of a spectrum of frequencies or related quantities such as energies etc. Purpose of estimating the spectral density is to detect any periodicities in the data, by observing peaks at the frequencies corresponding to these periodicities.

A Sinusoidal Signal

sin(2π10t+π/3)+sin(2π15t)sin(2\pi10t +\pi/3)+sin(2\pi15t)

is generated and plotted . It's is transformed into frequency domain to analyze it's frequency spectrum and energy spectrum.

MATLAB COMMANDS USED

* plot(x,y,color,properties)
* sin(t);
* fft(x,n)
* fftshift(x)
* conj(x)

MATLAB CODE

f1=10;
f2=15;
sampleFactor=30;
fs=sampleFactor*f;
phase=pi/3;
nCyl=5;
t=0:1/fs:1;

x=sin(2*pi*f1*t +phase)+sin(2*pi*f2*t);
subplot(2,2,1);
plot(t,x,'LineSmoothing','on');
title('X(t) is sin(2\pi15t) + sin(2\pi10t) ');
xlabel('time (sec)');
ylabel(' Amplitude  X(t)');
mx=max(x);
axis([0 1 -1.2*mx 1.2*mx]);

NFFT=1024;
X=fftshift(fft(x,NFFT));
fVals=fs*(-NFFT/2:NFFT/2-1)/NFFT;
subplot(2,2,2);
plot(fVals,X,'LineSmoothing','on','LineWidth',1);
title('Double Sided FFT with FFTshift');
ylabel('|DFT values|');
xlabel('Frequency (Hz)');
f=max(f1,f2)+10;
mX=1.1*abs(max(X));
axis([-f f -10 mX]);

L=length(x);
Px=X.*conj(X)/(NFFT*L);
subplot(2,2,3);
plot(fVals,Px,'LineSmoothing','on','LineWidth',1);
title('Power Spectral Density');
ylabel('Power');
xlabel('Frequency (Hz)');
axis([-f f 0 mp]);

sVals=fs*(0:NFFT/2-1)/NFFT;
subplot(2,2,4);
plot(fVals,Px,'LineSmoothing','on','LineWidth',1);
title('One Sided Power Spectral Density');
ylabel('Power spectral density');
xlabel('Frequency (Hz)');
axis([0 f  0 mp]);
grid on;
print('sinefft','-dpng');

RESULT

The Spectral Analysis of Sinusoidal signal has been done and required graphs plotted have been plotted.