You are on page 1of 17

BTEC408

BTEC408 Lab Signal & Systems Using MATLAB (4 Semester)


th

Submitted By: College Roll No: University Roll No:

Lab Signal & Systems Using MATLAB

Page 1

BTEC408

CONTENTS
EXPERIMENT 1: Generation of continuous and Discrete Unit step signal......................................... 3 EXPERIMENT 2: Generation of exponential and Ramp signal in Continuous and Discrete domain. 4 EXPERIMENT 3: Continuous and Discrete time Convolution. ........................................................... 6 EXPERIMENT 4: Adding and subtracting two Given Signal ............................................................. 8 EXPERIMENT 5: To plot CDF and PDF of Rayleigh distribution, Gaussian distribution and uniform distribution. ........................................................................................................................................... 10 EXPERIMENT 6: Write a program to show signal shifting............................................................... 12 EXPERIMENT 7: Write a program to show Folding of a Signal....................................................... 13 EXPERIMENT 8: Write a program to show signal scaling. .............................................................. 14 EXPERIMENT 9: To study Power Spectral Density ......................................................................... 15 EXPERIMENT 10: Write a program to compute Z -Transform and Inverse Z -Transform. ............. 17

Lab Signal & Systems Using MATLAB

Page 2

BTEC408

EXPERIMENT No.1
AIM: Generation of continuous and Discrete Unit step signal. PROGRAM: % EXperiment 1 Generation of continuous and Discrete Unit step signal. x=0:10; y=ones(1,11); subplot(1,2,1); plot(x,y, 'b'); title('continous unit step (u(t))'); xlabel('time (t)'); ylabel('u(t)'); axis([-10 10 -.5 1.5]) grid on; subplot(1,2,2); stem(x,y,'b'); title('discrete unit step (u(n))'); xlabel('time (n)'); ylabel('u(n)'); axis([-10 10 -.5 1.5]) grid on; OUTPUT:
continous unit step (u(t)) 1.5 1.5 discrete unit step (u(n))

0.5

u(n)

u(t)

0.5

-0.5 -10

-5

0 time (t)

10

-0.5 -10

-5

0 time (n)

10

Lab Signal & Systems Using MATLAB

Page 3

BTEC408

EXPERIMENT No.2
AIM: Generation of exponential and Ramp signal in Continuous and Discrete domain. PROGRAM: % Experiment 2 Generation of exponential and Ramp Signal in Continuous and Discrete Domain. x=[0:10]; y=x subplot(2,2,1) plot(x,y) xlabel('time(t)') ylabel('r(t)') title('ramp signal r(t)') grid on subplot(2,2,3) stem(x,y) xlabel('time(n)') ylabel('r(n)') title ('ramp signal (r(n))') grid on z=exp(x) subplot(2,2,2) plot(z) xlabel('time(t)') ylabel('exp(t)') title('exp(t)') grid on subplot(2,2,4) stem(z) xlabel('discrete(n)') ylabel('exp(n)') title('exp(n)') grid on

Lab Signal & Systems Using MATLAB

Page 4

BTEC408

OUTPUT:
ramp signal r(t) 10 8 6 2.5 2 1.5 1 0.5 0 x 10
4

exp(t)

4 2 0

4 time(t)

10

exp(t)

r(t)

6 time(t) exp(n)

10

12

ramp signal (r(n)) 10 8 6 2.5 2 1.5 1 0.5 0

x 10

4 2 0

4 time(n)

10

exp(n)

r(n)

6 time(n)

10

12

Lab Signal & Systems Using MATLAB

Page 5

BTEC408

EXPERIMENT No.3
AIM: Continuous and Discrete time Convolution. PROGRAM: % Experiment 3 Continuous and Discrete time Convolution. x=0:15; y=x; subplot(3,2,1); stem(x,y) title('sequence1 x(n)') ylabel('x(n)') xlabel('time(n)') grid on subplot(3,2,2) plot(x,y) title('sequence1 x(t)') ylabel('x(t)') xlabel('time(t)') grid on a=0:15; b=exp(a); subplot(3,2,3); stem(a,b) title('sequence2 h(n)') ylabel('h(n)') xlabel('time(n)') grid on subplot(3,2,4) plot(a,b) title('sequence2 h(t)') ylabel('h(t)') xlabel('time(t)') grid on z=conv(y,b) subplot(3,2,5) stem([0:30],z) title('y(n)=x(n)*h(n)[convolution]') ylabel('y(n)') xlabel('time(n)') grid on subplot(3,2,6) plot([0:30],z) title('y(t)=x(t)*h(t)[convolution]') ylabel('y(t)') xlabel('time(t)') grid on

Lab Signal & Systems Using MATLAB

Page 6

BTEC408

OUTPUT:
sequence1 x(n) 15 10 15 10 sequence1 x(t)

x(n)

5 0

x(t)
5 0 0 x 10
6

10

15

0 x 10
6

time(n) sequence2 h(n) 4 3

10 time(t) sequence2 h(t)

15

4 3

h(n)

2 1 0 0 x 10
7

h(t)
5 10 15

2 1 0 0 x 10
7

time(n) y(n)=x(n)*h(n) [convolution] 8 6

10 time(t) y(t)=x(t)*h(t) [convolution]

15

8 6

y(n)

4 2 0 0 5 10 15 time(n) 20 25 30

y(t)

4 2 0 0 5 10 15 time(t) 20 25 30

Lab Signal & Systems Using MATLAB

Page 7

BTEC408

EXPERIMENT 4
AIM: Adding and subtracting two Given Signal (Continues as well as Discrete Signals) PROGRAM: % Experiment 4 Adding and subtracting two Given Signals (Continues as well as Discrete Signals) x= 0:15; y=randint(1,16,[1,7]) subplot(4,2,1); stem(x,y) axis([0 15 0 10]) title('sequence 1 y(n)') ylabel('y(n)') xlabel('time(n)') grid on subplot (4,2,2) plot(x,y) axis([0 15 0 10]) title('sequence 1 y(t)') ylabel('y(t)') xlabel('time(t)') grid on v=randint(1,16,[2,9]); subplot(4,2,3); stem(x,v) axis([0 15 0 10]) title('sequence 2 v(n)') ylabel('v(n)') xlabel('time(n)') grid on subplot(4,2,4); plot(x,y) axis([0 15 0 10]) title('sequence 2 v(t)') ylabel('v(t)') xlabel('time(t)') grid on subplot(4,2,5); p=y+v; stem(x,p) title('sum sequences v(n) & y(n)') ylabel('p(n)') xlabel('time(n)') axis([0 15 -10 20]) grid on subplot (4,2,6); plot(x,p) title('sum sequences v(t) & y(t)') xlabel('time(t)') ylabel('p(t)')
Page 8

Lab Signal & Systems Using MATLAB

BTEC408

axis([0 15 -10 20]) grid on subplot (4,2,7); q=y-v; stem(x,q) title('subtract sequences v(n) & y(n)') xlabel('time(n)') ylabel('q(n)') axis([0 15 -10 20]) grid on subplot(4,2,8); plot(x,q) title('subtract sequences v(t) & y(t)') xlabel('time(t)') ylabel('q(t)') axis([0 15 -10 20]) grid on OUTPUT:

sequence 1 y(n) 10 10

sequence 1 y(t)

y(n)

5 0

y(t)
0 5 10 15

5 0

time(n) sequence 2 v(n) 10 10

10 time(t) sequence 2 v(t)

15

v(n)

5 0

v(t)
0 5 10 15

5 0

time(n) sum sequences v(n) & y(n) 20 20

10 time(t) sum sequences v(t) & y(t)

15

p(n)

0 -10 0 10 time(n) subtract sequences v(n) & y(n) 5 15

p(t)

10

10 0 -10 0 10 time(t) subtract sequences v(t) & y(t) 5 15

20

20

q(n)

0 -10 0 5 time(n) 10 15

q(t)

10

10 0 -10 0 5 time(t) 10 15

Lab Signal & Systems Using MATLAB

Page 9

BTEC408

EXPERIMENT 5
AIM: To plot CDF and PDF of Rayleigh distribution, Gaussian distribution and uniform distribution. PROGRAM: % Experiment 5 To plot cdf pdf of Rayleigh distribution Gaussian distribution and uniform distribution. x= [0:0.1:3]; p= raylpdf(x,1); subplot(2,3,1) plot(x,p) title('releigh pdf') grid on k=[0:0.1:4] z=raylcdf(k,1); subplot(2,3,4) plot(k,z) title('releigh cdf') grid on [xk ,p]= raylstat(1) r= raylrnd(1:5) q=[0:2:4:8]; median_value = unifinv(q) subplot(2,3,2) plot(q) title('uniform pdf') grid on o=[1:2:5:7]; probabitity = unifcdf(o) subplot(2,3,5) plot(o) title('uniform cdf') grid on a = 1:6; b = 2.*a; [m,v] = unifstat(a,b) x1 = random('Normal',0,1,2,4) x1 = pdf('Normal',-30:30,.1,1) subplot(2,3,3) plot(x1) title('gaussian pdf') grid on p1 = cdf('Normal',-25:25,0,1) subplot(2,3,6) plot(p1) title('gaussian cdf') grid on

Lab Signal & Systems Using MATLAB

Page 10

BTEC408

n = 1:5; [m,v] = normstat(n'*n,n'*n) OUTPUT:


releigh pdf 0.7 0.6 0.5 0.4 4 0.3 0.2 0.1 0 0 1 2 3 0 0 5 10 0 0 50 100 2 0.1 0.2 6 0.3 8 uniform pdf 0.4 gaussian pdf

releigh cdf 1 0.8 0.6 4 0.4 3 0.2 0 2 0 2 4 1 0 7 6 5

uniform cdf 1 0.8 0.6 0.4 0.2 0

gaussian cdf

10

20

40

60

Lab Signal & Systems Using MATLAB

Page 11

BTEC408

EXPERIMENT 6
AIM: Write a program to show signal shifting. PROGRAM: % experiment for signal shifting x=-100:100; y=zeros(1,length(x)); N=input('plz enter the value of N') for a=(((length(x)+1))/2-(N)):length(x) y(a)=1; end stem(x,y) axis([-100 100 -1 2]) grid on OUTPUT:
u(n) 2

amplitude

1 0 -1 -100

-80

-60

-40

-20

0 time(n) u(n+40)

20

40

60

80

100

amplitude

1 0 -1 -100

-80

-60

-40

-20

0 time(n) u(n-40)

20

40

60

80

100

amplitude

1 0 -1 -100

-80

-60

-40

-20

0 time(n)

20

40

60

80

100

Lab Signal & Systems Using MATLAB

Page 12

BTEC408

EXPERIMENT 7
AIM: Write a program to show Folding of a Signal. PROGRAM: % experiment folding of a signal a=randint(1,11,8); b=-5:5; subplot(1,2,1) stem(b,a) subplot(1,2,2) stem(b,fliplr(a))

OUTPUT:
x(n) 7 7 x(-n)

amplitude

amplitude
0 time(n) 5

0 -5

0 -5

0 time (n)

Lab Signal & Systems Using MATLAB

Page 13

BTEC408

EXPERIMENT 8
AIM:Write a program to show signal scaling. PROGRAM: %experiment scaling of a signal x=-4:4; y=[0 1 2 3 4 3 2 1 0]; subplot(3, 1, 1) stem(x,y) axis([-12 12 -1 5]) grid on A=input('enter the speeding factor A x(An)') z=x/A; subplot(3, 1, 2) stem(z,y) axis([-12 12 -1 5]) grid on A=input('enter the slowdown factor A x(n/A)') p=x*A; subplot(3, 1, 3) stem(p,y) axis([-12 12 -1 5]) grid on OUPTPUT:
x(n) 4

amplitude

2 0 -10 -5 0 time(n) x(2n) 5 10

amplitude

2 0 -10 -5 0 time(n) u(n/2) 5 10

amplitude

2 0 -10 -5 0 time(n) 5 10

Lab Signal & Systems Using MATLAB

Page 14

BTEC408

EXPERIMENT 9
AIM: To study Power Spectral Density PROGRAM: %experiment to study power spectral density % create random data t = 0:.001:.25; x = sin(2*pi*50*t) + sin(2*pi*120*t); % Add some random noise y = x + 2*randn(size(t)); plot(y(1:50)) grid on title('Noisy time domain signal') % take the fast-Fourier transform (FFT). Y = fft(y,256); % Compute the power spectral density Pyy = Y.*conj(Y)/256; f = 1000/256*(0:127); figure(2) plot(f,Pyy(1:128)) grid on title('Power spectral density') xlabel('Frequency (Hz)') OUTPUT:
Noisy time domain signal 6

amplitude

-2

-4

-6

10

15

20

25 time

30

35

40

45

50

Lab Signal & Systems Using MATLAB

Page 15

BTEC408

Power spectral density 90

80

70

60

50

40

30

20

10

50

100

150

200

250 300 Frequency (Hz)

350

400

450

500

Lab Signal & Systems Using MATLAB

Page 16

BTEC408

EXPERIMENT 10

AIM: Write a program to compute Z -Transform and Inverse Z -Transform. PROGRAM: %experiment computing Z-Transform and Inverse Z-transform syms n % define the time domain sequence 'f' disp('f = time domain sequnce') f = n^4; disp(f) % compute z transform of 'f' disp('y = z transform of (f)') y=ztrans(f); disp(y) % compute inverse z transform of z domain sequence 'y' disp('a = inverse z transform of z domain sequence (y)') a=iztrans(y); disp(a) OUTPUT:

f = time domain sequnce n^4

y = z transform of (f) z*(z^3+11*z^2+11*z+1)/(z-1)^5

a = inverse z transform of z domain sequence (y) n^4

Lab Signal & Systems Using MATLAB

Page 17

You might also like