Saturday, July 9, 2011

First Three Matlab Programs of DSP Lab

Dear All Students,

   I am uploading the first three programs of DSP Lab which you have to do on this monday. You should have these programs in your book( not observations book). Try to copy the code in some book and try the code on monday's lab and try to observe the results. If results are okay then do copy in observations and get it signed on monday only.

Instructions to write observations: 
On Right Side of the Observations:
a) you have to mention AIM 
b) Then mention software required(if version of the software is known then mention it)
c) Then follows Program Code
d) Write the Result

On Left Side of the Observations:
a) show the output result.(If any figures are there then u have to draw it neatly and clearly and it should be also drawn on Graph Sheet.)
b) Write the Result with Pencil only.

These are few Instructions.

Below follows the Matlab code for 1) Generating Sinusoidal Signals and finding Summation, 2) Linear Convolution, 3) N-Point FFT Calculation.


1.Matlab code to generate sum of sinusoidal signals

 

Title('sum of sine waves');

t=0:0.5:2*pi;

y=sin(t);

subplot(4,2,1)

stem(y)

xlabel('n');

ylabel('amplitude');

title('sinewave');

subplot(4,2,2);

plot(y);

xlabel('n');

ylabel('amplitude');

title('sinewave');

y1=sin(t)+5*sin(2*t);

subplot(4,2,3);

xlabel('n');

ylabel('amplitude');

title('sinewave with harmonics');

subplot(4,2,4);

stem(y1);

xlabel('n');

ylabel('amplitude');

title('sinewave with harmonics');

y2=sin(t)+5*sin(2*t)+10*sin(3*t);

subplot(4,2,5);

stem(y2);

xlabel('n');

ylabel('amplitude');

title('sinewave with two harmonics');

subplot(4,2,6);

plot(y2);

xlabel('n');

ylabel('amplitude');

title('sine wave with two harmonics');

y3=sin(t)+5*sin(2*t)+10*sin(3*t)+15*sin(4*t);

subplot(4,2,7);

stem(y3);

xlabel('n');

ylabel('amplitude');

title('sinewave with three harmonics');

subplot(4,2,8);

plot(y3);

xlabel('n');

ylabel('amplitude');

 

2.Matlab Program to verify Linear Convolution

 

x=input('Enter Input Sequence:');

y=input('Enter Impulse Response:');

y=conv(x,h);

subplot(3,1,1);

stem(x);

ylabel('amplitude');

xlabel('a');

title('input signal');

subplot(3,1,2);

stem(h);

ylabel('amplitude');

xlabel('b');

title('Impulse Response');

subplot(3,1,3);

stem(y);

ylabel('amplitude');

xlabel('c');

title('Linear Convolution');

disp('The Resultant Signal is:');

disp(y)

 

3.Matlab Program to find N-Point fft of a sequence

 

x=input('Enter the Sequence:');

n=input('Enter the Length of FFT:');

y=fft(x,n);

subplot(2,1,1);

stem(x);

title('Input Sequence');

xlabel('time index n');

ylabel('Amplitude');

subplot(2,1,2);

stem(y);

title('output sequence');

xlabel('frequency index');

ylabel('amplitude');


with regards,

B V K

No comments:

Post a Comment