Professional Documents
Culture Documents
S&S Lab File PDF
S&S Lab File PDF
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
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
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
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
x 10
4 2 0
4 time(n)
10
exp(n)
r(n)
6 time(n)
10
12
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
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
15
4 3
h(n)
2 1 0 0 x 10
7
h(t)
5 10 15
2 1 0 0 x 10
7
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
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
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
15
v(n)
5 0
v(t)
0 5 10 15
5 0
15
p(n)
p(t)
10
20
20
q(n)
0 -10 0 5 time(n) 10 15
q(t)
10
10 0 -10 0 5 time(t) 10 15
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
Page 10
BTEC408
gaussian cdf
10
20
40
60
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
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)
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
amplitude
amplitude
2 0 -10 -5 0 time(n) 5 10
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
Page 15
BTEC408
80
70
60
50
40
30
20
10
50
100
150
200
350
400
450
500
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:
Page 17