Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
50 views38 pages

Lab Manual of Digital Signal Processing: Prepared By: Asst. Prof. J.N.Vala

The document is a lab manual for digital signal processing. It contains 10 experiments including generating sinusoidal signals, ramp signals, delayed ramp signals, unit step signals, exponential functions, circles, and overdamped and underdamped oscillations using MATLAB commands and functions. The experiments provide step-by-step instructions on how to generate and plot various signals using MATLAB.

Uploaded by

jaydeepjaydeep
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views38 pages

Lab Manual of Digital Signal Processing: Prepared By: Asst. Prof. J.N.Vala

The document is a lab manual for digital signal processing. It contains 10 experiments including generating sinusoidal signals, ramp signals, delayed ramp signals, unit step signals, exponential functions, circles, and overdamped and underdamped oscillations using MATLAB commands and functions. The experiments provide step-by-step instructions on how to generate and plot various signals using MATLAB.

Uploaded by

jaydeepjaydeep
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 38

LAB MANUAL

Of
DIGITAL SIGNAL PROCESSING

Prepared By: Asst. Prof. J.N.Vala


DIGITAL SIGNAL PROCESSING

INDEX

Sr. TITLE
No.
1 BASIC MATLAB COMMANDS
2 TO GENERATE Sin-Cos SIGNALS
3 TO GANERATE RAMP SIGNAL
4 TO GENERATE DELAYED RAMP SIGNAL
5 TO GENERATE UNIT STEP SIGNAL
6 TO GENERATE EXPONENTIAL FUNCTION
7 TO GENERATE CIRCLE
8 TO GENERATE OVERDAMPPED & UNDERDAPPED OSCILLATION
9 TO SIMULATE AM, FM, PM USING SIMULINK
10 TO GENERATE CONTINUOUS AND SAMPLED SIGNAL WITH
HOLDING FUNCTION

Prepared By: Asst. Prof. J.N.Vala


EXPERIMENT 1 BASIC MATLAB COMMANDS
>> a=[1 2 3;4 5 6;7 8 9]

a=

1 2 3

4 5 6

7 8 9

This forms a 3X3 matrix labeled as a

>> b=a'

b=

1 4 7

2 5 8

3 6 9

The transpose of matrix a is stored in matrix b

>> c=b*a

c=

66 78 90

78 93 108

90 108 126

Multiplies matrix b with a stores in c

>> c=a*b

c=

14 32 50

32 77 122

50 122 194

DSPFILEUCET

Multiplies matrix a with b stores in c

>> a=[1 2 3 4 5]

a=

1 2 3 4 5

One dimensional array is defined as a

>> b=a+3

b=

4 5 6 7 8

3 is added to each element of a

>> c=a+b

c=

5 7 9 11 13

Both array a and b are stored in c

>> eye(3)

ans =

1 0 0

0 1 0

0 0 1

Identical matrix formed

>> eye(5)

ans =

1 0 0 0 0

0 1 0 0 0

0 0 1 0 0

0 0 0 1 0
DSPFILEUCET

0 0 0 0 1

5X5 identical matrix formed

>> zeros(4,4)

ans =

0 0 0 0

0 0 0 0

0 0 0 0

0 0 0 0

4X4 matrix with all elements 0

>> ones(4,3)

ans =

1 1 1

1 1 1

1 1 1

1 1 1

4X3 matrix with all elements 1

>> [eye(2);zeros(2)]

ans =

1 0

0 1

0 0

0 0

Identical matrix is appended with 2X2 zero matrix

DSPFILEUCET

>> [eye(2),zeros(2)]

ans =

1 0 0 0

0 1 0 0

Identical matrix is appended with the 2X2 zeros matrix and 2X4 matrix is formed

>> a=[1 2 3;4 5 6;7 8 9]

a=

1 2 3

4 5 6

7 8 9

This forms a 3X3 matrix labeled as a

>> a(2,1)

ans =

This gives the value of 2nd row and 1st column element

>> a(1,2)

ans =

This gives the value of 1st row and 2nd column element

>> c=[a;10 11 12]

c=

1 2 3

4 5 6

7 8 9
DSPFILEUCET

10 11 12

It appends a row in the matrix a

>> [a;a;a]

ans =

1 2 3

4 5 6

7 8 9

1 2 3

4 5 6

7 8 9

1 2 3

4 5 6

7 8 9

This appends a to itself one after another and forms 9X3 matrix

>> [a,a;a,a]

ans =

1 2 3 1 2 3

4 5 6 4 5 6

7 8 9 7 8 9

1 2 3 1 2 3

4 5 6 4 5 6

7 8 9 7 8 9

This appends matrix a on both the directions and forms 6X6 matrix

>> f=[0.5 0.47 0.1]

f=
DSPFILEUCET

0.5000 0.4700 0.1000

It defines a row matrix with non integer elements

>> round(f)

ans =

1 0 0

It assigns the nearest integer value

>> ceil(f)

ans =

1 1 1

It assigns the highest integer value

>> sum(f)

ans =

1.0700

Sum of all elements stored in matrix

>> fix(f)

ans =

0 0 0

The integer value is stored and the decimal value is discarded

>> floor(f)

ans =

0 0 0

It stores the lower nearest integer value

>> [1 2 3 4].*[1 2 3 4]

ans =

1 4 9 16
DSPFILEUCET

It directly multiplies each element of 1st matrix with 2nd matrix

>> [1 2 3 4]+[1 2 3 4]

ans =

2 4 6 8

It directly adds each element of 1st matrix with 2nd matrix

>> [1 2 3 4].^3

ans =

1 8 27 64

It makes cube of each elements of row matrix

>> [1 2 3 4]*3

ans =

3 6 9 12

It multiplies each elements of row matrix with 3.

>> pi

ans =

3.1416

The value of pi is displayed

>> eps

ans =

2.2204e-016

The value of e is displayed

>> who

Your variables are:

a b c f

ans
DSPFILEUCET

Displays all variables used

>> clear a

Your variables are:

ans b c f

Clear the variable a

>> clear all

Clears all the variables

>> x = -2:1

x=

-2 -1 0 1

It forms series of integer from -2 to 1 with unit difference

>> x=[1 2 3 4 6 7]

x=

1 2 3 4 6 7

>> length(x)

ans =

It gives length of series

>> t=0:2:10

t=

0 2 4 6 8 10

It gives series from 0 to 10 with difference of 2

DSPFILEUCET

>> a=magic(3)

a=

8 1 6

3 5 7

4 9 2

>> a(2,:)

ans =

3 5 7

It displays 2nd row with all elements

>> a(:,3)

ans =

It displays 3rd column with all elements

>> a(2:3,:)

ans =

3 5 7

4 9 2

It displays 2nd and 3rd row with all elements

>> b=rand(5)

b=

0.9501 0.7621 0.6154 0.4057 0.0579

0.2311 0.4565 0.7919 0.9355 0.3529


DSPFILEUCET

0.6068 0.0185 0.9218 0.9169 0.8132

0.4860 0.8214 0.7382 0.4103 0.0099

0.8913 0.4447 0.1763 0.8936 0.1389

It generates a random 5X5 matrix

>> c=100*rand(3)

c=

20.2765 27.2188 74.6786

19.8722 19.8814 44.5096

60.3792 1.5274 93.1815

It multiplies each element of random matrix with 100

>> [eye(2);zeros(2);zeros(2)]

ans=

1 0
0 1
0 0
0 0

0 0

0 0

DSPFILEUCET

EXPERIMENT 2 TO GENERATE Sin-Cos SIGNALS

clc;

clear all;

f=input('enter the freq.:');

t=0:1/(100*f):(8/f);

x=sin(2*pi*f*t);

y=cos(2*pi*f*t);

subplot(2,1,1);

plot(t,x);

subplot(2,1,2);

plot(t,y);

xlabel('Time');

ylabel('Amplitude');

enter the freq.:20

>>

DSPFILEUCET

0.5

-0.5

-1
0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4

0.5
Amplitude

-0.5

-1
0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4
Time

DSPFILEUCET

EXPERIMENT 3 TO GANERATE RAMP SIGNAL


clc;

clear all;

a=input('enter the value:');

n=0:1:a-1;

g=length(n);

x=n;

subplot(2,1,1);

plot(n,x);

subplot(2,1,2);

stem(n,x);

xlabel('Samples');

ylabel('Amplitude');

------------

enter the value:15

15

10

0
0 2 4 6 8 10 12 14

15
Amplitude

10

0
0 2 4 6 8 10 12 14
Samples

DSPFILEUCET

EXPERIMENT 4 TO GENERATE DELAYED RAMP


SIGNAL
clc;

clear all;

a=input('enter the value:');

d=input('enter the delay:');

n=1:1:a;

for i=1:1:d

x(i)=0;

end

for i=d:1:a

x(i)=i-d;

end

subplot(2,1,1);

plot(n,x);

subplot(2,1,2);

stem(n,x);

xlabel('Sample');

ylabel('Amplitude');

enter the value:15

enter the delay:3

>>

DSPFILEUCET

15

10

0
0 5 10 15

15

10
Amplitude

0
0 5 10 15
Sample

DSPFILEUCET

EXPERIMENT 5 TO GENERATE UNIT STEP SIGNAL


clc;

clear all;

a=input('enter the value:');

n=0:1:a-1;

g=length(n);

q=[ones(1,g)+ones(1,g)];

subplot(2,1,1);

plot(n,q);

subplot(2,1,2);

stem(n,q);

xlabel('Samples');

ylabel('Amplitude');

enter the value:10

>>

DSPFILEUCET

2.5

1.5

1
0 1 2 3 4 5 6 7 8 9

1.5
Amplitude

0.5

0
0 1 2 3 4 5 6 7 8 9
Samples

DSPFILEUCET

EXPERIMENT 6 TO GENERATE EXPONENTIAL


FUNCTION
clc;

clear all;

close all;

k=input('Enter the slope :');

t=0:0.01:k-1;

n=exp(10*t);

plot(t,n);

Enter the slope :1.5

>>

150

100

50

0
0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5

DSPFILEUCET

DSPFILEUCET

EXPERIMENT 7 TO GENERATE CIRCLE


clc;

clear all;

close all;

theta=0:0.01:100;

r=input('enterthe radius:');

x=r*cos(theta);

y=r*sin(theta);

plot(x,y);

grid;

--------------

enterthe radius:15

>>

15

10

-5

-10

-15
-15 -10 -5 0 5 10 15

DSPFILEUCET

EXPERIMENT 8 TOGENERATEOVERDAMPPED&
UNDERDAPPEDOSCILLATION
(1) OVERDAPPED

clc;

clearall;

closeall;

a=input('Enterthevariable:');

t=0:1:100;

x=sin(t);

y=exp(a*t);

z=x.*y;

plot(t,z);

xlabel('Time');

ylabel('Amplitude');

title('OverdmppedOscillations');

grid;

Enterthevariable:0.05

>>

DSPFILEUCET

Overdmpped Oscillations
150

100

50
Amplitude

-50

-100

-150
0 10 20 30 40 50 60 70 80 90 100
Time

(2) UNDERDAPPED

clc;

clearall;

closeall;

a=input('Enterthevariable:');

t=0:1:100;

x=sin(t);

y=exp(a*t);

z=x.*y;

plot(t,z);

xlabel('Time');
DSPFILEUCET

ylabel('Amplitude');

title('UnderdmppedOscillations');

grid;

Enterthevariable:0.05

>>

Underdmpped Oscillations
1

0.8

0.6

0.4
Amplitude

0.2

-0.2

-0.4

-0.6

-0.8
0 10 20 30 40 50 60 70 80 90 100
Time

DSPFILEUCET

EXPERIMENT 9 TO SIMULATE AM, FM, PM


USING SIMULINK
9(a)ToproduceAMmodulationsystemusingSimulink.

DSPFILEUCET

DSPFILEUCET

9(b)ToproduceAMdemodulationsystemusingSimulink.

DSPFILEUCET

9(c)ToproduceFMmodulationsystemusingSimulink.

DSPFILEUCET

DSPFILEUCET

9(d)ToproduceFMdemodulationsystemusingSimulink.

DSPFILEUCET

DSPFILEUCET

9(e)ToproducePMmodulationsystemusingSimulink.

DSPFILEUCET

DSPFILEUCET

9(f)ToproducePMDemodulationsystemusingSimulink.

DSPFILEUCET

DSPFILEUCET

EXPERIMENT 10 TO GENERATE CONTINUOUS AND


SAMPLED SIGNAL WITH HOLDING
FUNCTION

clc;

clearall;

t=0:0.5:25;

y=sin(t);

plot(t,y);

title('SINEWAVE&SAMPLEDOUTPUT');

xlabel('TIME');

ylabel('AMPLITUDE');

holdon;

stem(t,y);

holdon;

stairs(t,y);

DSPFILEUCET

DSPFILEUCET

You might also like