SS Lab Manual
SS Lab Manual
NAME: __________________________________________
CLASS: __________________________________________
1
Signals and Systems Lab
List of Experiments
(Minimum Twelve experiments to be conducted)
1. Basic operations on Matrices
2. Generation of Various signals and Sequences (Periodic and Aperiodic), Such as Unit Impulse,
Unit Step, Square, Saw Tooth, Triangular, Sinusoidal, Ramp, sinc function.
3. Operations on Signals and Sequences such as Addition, Multiplication, Scaling, Shifting,
Folding, Computation of Energy and Average power.
4. Finding the Even and Odd parts of Signal or Sequence and Real and Imaginary parts of Signal.
5. Convolution between Signals and Sequences.
6. Autocorrelation and Cross correlation between Signals and Sequences.
7. Verification of Linearity and Time Invariance properties of a Given Continuous / Discrete
System.
8. Computation of Unit Sample, Unit Step and Sinusoidal Responses of the given LTI system and
verifying its Physical Realizability and Stability properties.
9. Gibbs phenomenon.
10. Finding the Fourier Transform of a given Signal and plotting its Magnitude and phase
Spectrum.
11. Waveform Synthesis using Laplace Transform.
12. Locating Zeros and poles, and plotting the Pole-Zero maps in S-Plane and Z-Plane for the given
Transfer Functions.
13. Generation of Gaussian Noise (Real and Complex), Computation of its Mean, M.S. Values and
its Skew, Kurtosis, and PSD, Probability Distribution Function.
14. Sampling Theorem Verification.
2
Signals and Systems Lab
INDEX
3
Signals and Systems Lab
Experiment No-1
SOFTWARE REQURIED:-
MATLAB R2010a
PROCEDURE:-
Open MATLAB
Open new M-file
Type the program
Save in current directory
Compile and Run the program
For the output see command window\ Figure window
PROGRAM:-
clc;
close all;
clear all;
a=[1 2 -9 ; 2 -1 2; 3 -4 3];
b=[1 2 3; 4 5 6; 7 8 9];
disp('The matrix a= ');a
disp('The matrix b= ');b
% to find sum of a and b
c=a+b;
disp('The sum of a and b is ');c
% to find difference of a and b
d=a-b;
disp('The difference of a and b is ');d
%to find multiplication of a and b
e=a*b;
disp('The product of a and b is ');e
% to find element-by-element multiplication
RESULT:- Thus Matlab Program to perform some basic operations on matrices has been executed
successfully.
4
Signals and Systems Lab
OUTPUT:-
The matrix a=
a=
1 2 -9
2 -1 2
3 -4 3
The matrix b=
b=
1 2 3
4 5 6
7 8 9
c=
2 4 -6
6 4 8
10 4 12
d=
0 0 -12
-2 -6 -4
-4 -12 -6
e=
5
Signals and Systems Lab
Experiment No-2a
SOFTWARE REQURIED :-
MATLAB R2010a
PROCEDURE:-
Open MATLAB
Open new M-file
Type the program
Save in current directory
Compile and Run the program
For the output see command window\ Figure window
PROGRAM:-
clc;
clear all;
close all;
n=-10:1:10;
L=length(n);
for i=1:L
if n(i)==0
x1(i)=1;
else
x1(i)=0;
end;
if n(i)>=0
x2(i)=1;
x3(i)=n(i);
else
x2(i)=0;
x3(i)=0;
end;
end;
% to generate exponential sequence
a=0.85;
x4=a.^n;
% to generate sinusoidal sequence
f=0.1;
x5=sin(2*pi*f*n);
figure;
subplot(3,2,1);
6
Signals and Systems Lab
stem(n,x1);
xlabel('time n ---->');
ylabel('amplitude---->');
title('Unit step signal');
subplot(3,2,2);
stem(n,x2);xlabel('time n ---->');
ylabel('amplitude---->');
title('Unit impluse signal')
subplot(3,2,3);
stem(n,x3);
xlabel('time n ---->');
ylabel('amplitude---->');
title('Unit remp signal');
subplot(3,2,4);
stem(n,x4);xlabel('time n ---->');
ylabel('amplitude---->');
title('exponential signal');
subplot(3,2,[5,6]);
stem(n,x5);
xlabel('time n ---->');
ylabel('amplitude---->');
title('sinusoidal signal');
RESULT:- Thus the Generation of discrete time signals like unit impulse, unit step,unit ramp,
exponential signal and sinusoidal signals has been executed successfully by using Matlab.
OUTPUT:-
7
Signals and Systems Lab
8
Signals and Systems Lab
Experiment No-2b
AIM: -To write a “MATLAB” Program to generate of continuous time signals like
unit step, sawtooth, triangular, Sinusoidal, ramp, and sinc function.
SOFTWARE REQURIED :
MATLAB R2010a
.
PROCEDURE:-
Open MATLAB
Open new M-file
Type the program
Save in current directory
Compile and Run the program
For the output see command window\ Figure window
PROGRAM:-
clc;
Clear all;
Close all;
t=-10:0.01:10;
L=length(t);
for i=1:L
%to generate unit Step and ramp function
if t(i)<0
x1(i)=0;
x2(i)=0;
else
x1(i)=1;
x2(i)=t(i);
end;
end;
%to generate sinusoidal function
f=0.1;
x3=sin(2*pi*f*t);
%to generate Triangular and Sawtooth waveforms
x4=sawtooth(t,0.5);
x5=sawtooth(t);
9
Signals and Systems Lab
plot(t,x1);
xlabel('t--->');ylabel('amp--->');
title('unit step');
subplot(2,3,2);
plot(t,x2);
xlabel('t--->');ylabel('amp--->');
title('unit ramp');
subplot(2,3,3);
plot(t,x3);
xlabel('t--->');ylabel('amp--->');
title('sinusoidal');
subplot(2,3,4);
plot(t,x4);
xlabel('t--->');ylabel('amp--->');
title('triangular');
subplot(2,3,5);
plot(t,x5);
xlabel('t--->');ylabel('amp--->');
title('sawtooth');
subplot(2,3,6);
plot(t,x6);
xlabel('t--->');ylabel('amp--->');
title('sinc function');
RESULT:- Thus continuous time signals like unit step, sawtooth, triangular, sinusoidal, ramp and
sinc functions has been executed successfully by using Matlab.
OUTPUT:-
10
Signals and Systems Lab
11
Signals and Systems Lab
Experiment No-03
SOFTWARE REQURIED :-
MATLAB R2010a
.
PROCEDURE:-
Open MATLAB
Open new M-file
Type the program
Save in current directory
Compile and Run the program
For the output see command window\ Figure window
PROGRAM:-
clc,
close all;
clear all;
t=0:0.001:1;
L=length(t);
f1=1;
f2=3;
x1=sin(2*pi*f1*t);
x2=sin(2*pi*f2*t);
figure;
subplot(3,2,1);
plot(t,x1,'b',t,x2,'r');
title('the signals x1(t) and x2(t)');
x3=x1+x2;
subplot(3,2,2);
plot(t,x3);
title('the sum of x1(t) and x2(t)');
x4=x1.*x2;
subplot(3,2,3);
plot(t,x4);
title('the multiplication of x1(t) and x2(t)');
t=-1:0.001:0;
x5=sin(2*pi*f1*(-t));
x6=sin(2*pi*f2*(-t));
12
Signals and Systems Lab
subplot(3,2,4);
plot(t,x5,'b',t,x6,'r');
title('the folding of x1(t)and x2(t)');
x7=[zeros(1,200),x2(1:(L-200))];
subplot(3,2,5);
plot(t,x7);
title('the shifting of x1(t)and x2(t)');
x8=x2.^2;
subplot(3,2,6);
plot(t,x8);
title('the squaring of x1(t)and x2(t)');
RESULT: - Thus the MATLAB Program to perform operations on signals has been executed
successfully.
OUTPUT:-
13
Signals and Systems Lab
Experiment No-4
SOFTWARE REQURIED :-
MATLAB R2010a
.
PROCEDURE:-
Open MATLAB
Open new M-file
Type the program
Save in current directory
Compile and Run the program
For the output see command window\ Figure window
PROGRAM:-
clc;
clear all;
close all;
t=-5:0.001:5;
A=0.8;
x1=A.^(t);
x2=A.^(-t);
if(x2==x1)
disp('The given signal is even signal');
else
if(x2==(-x1))
disp('The given signal is odd signal');
else
disp('The given signal is neither even nor odd');
end
end
xe=(x1+x2)/2;
xo=(x1-x2)/2;
subplot(2,2,1);
plot(t,x1);
xlabel('t');ylabel('x(t)');title('signal x(t)');
subplot(2,2,2);
plot(t,x2);
xlabel('t');ylabel('x(t)');title('signal x(-t)');
subplot(2,2,3);
plot(t,xe);
xlabel('t');ylabel('x(t)');title('even part signal x(t)');
14
Signals and Systems Lab
subplot(2,2,4);
plot(t,xo);
xlabel('t');ylabel('x(t)');title('odd part signal x(t)');
RESULT:- Thus the MATLAB Program to find even and odd parts of signals has been executed
successfully.
OUTPUT:-
15
Signals and Systems Lab
Experiment No-5
SOFTWARE REQURIED :-
MATLAB R2010a
.
PROCEDURE:-
Open MATLAB
Open new M-file
Type the program
Save in current directory
Compile and Run the program
For the output see command window\ Figure window
PROGRAM:-
clc;
clear all;
close all;
n=0:8;
x1=1;
x2=0;
y1=x1.*(n>=0 & n<=2)+x2.*(n>=2 & n<=8);
subplot(2,2,1);
stem(n,y1);
axis([0 8 0 1.5]);
xlabel('time n ---->');
ylabel('amplitude---->');
title('the sequence y1[n]')
y2=x1.*(n>=0 & n<=4)+x2.*(n>=4 & n<=8);
subplot(2,2,2);
stem(n,y2);
axis([0 8 0 1.5]);
xlabel('time n ---->');
ylabel('amplitude---->');
title('the sequence y2[n]')
y=conv(y1,y2);
L=length(y);
n=0:L-1;
subplot(2,2,[3,4]);
stem(n,y);
axis([0 10 0 4]);
xlabel('time n ---->');
16
Signals and Systems Lab
ylabel('amplitude---->');
title('the convolution sequence of y1[n]&y2[n]');
RESULT:- Thus the MATLAB Program to find the convolution of two sequences has been
executed successfully.
OUTPUT:-
17
Signals and Systems Lab
Experiment No-06
SOFTWARE REQURIED :-
MATLAB R2010a
.PROCEDURE:
Open MATLAB
Open new M-file
Type the program
Save in current directory
Compile and Run the program
For the output see command window\ Figure window
PROGRAM:
18
Signals and Systems Lab
subplot(2,2,2);
plot(t,x2);
title('sine wave x2');
xlabel('time ---->');,ylabel('amplitude---->');
grid;
[cxx lag2]=xcorr(x1,x2);
subplot(2,2,[3,4]);
plot(lag2,cxx);
grid;
title('cross-correlation function of sine wave');
RESULT:- Thus the MATLAB Program of computing auto correlation and cross correlation
between signals has been executed successfully.
OUTPUT:
19
Signals and Systems Lab
20
Signals and Systems Lab
Experiment No-7(a)
AIM: - To write a matlab program to verify the given system is linear or non-linear.
SOFTWARE REQURIED :-
MATLAB R2010a
PROCEDURE:-
Open MATLAB
Open new M-file
Type the program
Save in current directory
Compile and Run the program
For the output see command window\ Figure window
PROGRAM:-
clc; clear all; close all;
x1=input('enter the x1[n] sequence='); % [0 2 4 6]
x2=input('enter the x2[n] sequence='); % [3 5 -2 -5]
if length(x1)~=length(x2)
disp(' length of x2 must be equal to the length of x1');
return;
end;
h=input('enter the h[n] sequence=');% [-1 0 -3 -1 2 1]
a=input('enter the constant a= '); % 2
b=input('enter the constant b= '); % 3
y01=conv(a*x1,h);
y02=conv(b*x2,h);
y1=y01+y02;
x=a*x1+b*x2;
y2=conv(x,h);
L=length(x1)+length(h)-1;
n=0:L-1;
subplot(2,1,1);
stem(n,y1);
label('n --->'); label('amp ---->');
title('sum of the individual response');
subplot(2,1,2);
stem(n,y2);
xlabel('n --->'); ylabel('amp ---->');
title('total response');
if y1==y2
disp('the system is a Linear system');
else
disp('the system is a non-linear system');
end;
21
Signals and Systems Lab
RESULT:- Thus the MATLAB Program to verify the system is linear or non-linear has been
executed successfully.
INPUT SEQUENCE:
Enter the x1[n] sequence= [0 2 4 6]
Enter the x2[n] sequence= [3 5 -2 -5]
Enter the h[n] sequence= [-1 0 -3 -1 2 1]
Enter the constant a= 2 & enter the constant b= 3
The system is a linear system
OUTPUT:-
22
Signals and Systems Lab
Experiment No-07(b)
AIM: - To write a matlab program to verify the given system is Time –invariant
or Time–variant.
SOFTWARE REQURIED :-
MATLAB R2010a
PROCEDURE:-
Open MATLAB
Open new M-file
Type the program
Save in current directory
Compile and Run the program
For the output see command window\ Figure window
PROGRAM:-
23
Signals and Systems Lab
RESULT:- Thus the MATLAB Program to verify the system is Time –invariant or Time–variant
system has been executed successfully..
INPUT SEQUENCE:
Enter the sequence x[n] = [0 2 3 1 -2 7 3]
Enter the sequence h[n] = [4 -5 -11 -3 7 2 6 8 -15]
Enter the positive number for delay d=5
The given system is a Time-invariant system
OUTPUT:-
24
Signals and Systems Lab
25
Signals and Systems Lab
Experiment No-08
SOFTWARE REQURIED :-
MATLAB R2010a
.PROCEDURE:-
Open MATLAB
Open new M-file
Type the program
Save in current directory
Compile and Run the program
For the output see command window\ Figure window
PROGRAM:-
clc;
clear all;
close all;
syms s complex;
H=1/(s^2+4*s+3);
disp('Impulse response of the system h(t) is');
h=ilaplace(H);
simplify(h);
disp(h);
Y=1/(s*(s^2+4*s+3));
disp('Step response of the system is');
y=ilaplace(Y);
simplify(y);
disp(y);
t=0:0.1:20;
h1=subs(h,t);
subplot(2,1,1);
plot(t,h1);
xlabel('time');
ylabel('h(t)');
title('Impulse response of the system');
y1=subs(y,t);
subplot(2,1,2);
plot(t,y1);
xlabel('time');
ylabel('x(t)');
title('step response of the system');
26
Signals and Systems Lab
RESULT: - Thus Matlab program to find impulse response and step response of the LTI system
has been executed successfully.
OUTPUT:-
OUTPUT:
27
Signals and Systems Lab
Experiment No-9
GIBBS PHENOMENON
AIM: - To write a MATLAB program to construct the following p periodic signal represented by
its Fourier Series by considering only 3,9,59 terms.
SOFTWARE REQURIED :-
MATLAB R2010a
. PROCEDURE:-
Open MATLAB
Open new M-file
Type the program
Save in current directory
Compile and Run the program
For the output see command window\ Figure window
PROGRAM:-
clc;
clear all;
close all;
N=input('enter the no. of signals to reconstruct=');
n_har=input('enter the no. of harmonics in each signal=');
t=-1:0.001:1;
omega_0=2*pi;
for k=1:N
x=0.5;
for n=1:2:n_har(k)
b_n=2/(n*pi);
x=x+b_n*sin(n*omega_0*t);
end
subplot(N,1,k);
plot(t,x);
xlabel('time--->');
ylabel('amp---->');
axis([-1 1 -0.5 1.5]);
text(0.55,1.0,['no.of har=',num2str(n_har(k))]);
end
RESULT:- Thus, Gibbs Phenomenon has been executed successfully by using Matlab.
28
Signals and Systems Lab
OUTPUT:-
29
Signals and Systems Lab
Experiment No-10(a)
AIM: - To find Fourier transform and inverse Fourier transforms of given functions.
SOFTWARE REQURIED :-
MATLAB R2010a
.
PROCEDURE:-
. Open MATLAB
Open new M-file
Type the program
Save in current directory
Compile and Run the program
For the output see command window\ Figure window
PROGRAM:-
To find Fourier transform
30
Signals and Systems Lab
F1=A*pi*(dirac(w-o)+dirac(w+o));
f1=ifourier(F1,t);
disp('the inverse fourier transform of A*pi*(dirac(w-o)+dirac(w+o)=');
disp(f1);
F2=A*pi*(dirac(w-o)-dirac(w+o))/i;
f2=ifourier(F2,t);
disp('the inverse fourier transform of A*pi*(dirac(w-o)+dirac(w+o)/i=');
disp(f2);
F3=A/(1+i*w);
f3=ifourier(F3,t);
disp('the inverse fourier transform of A/(1+jw)=');
disp(f3);
F4=(3*i*w+14)/((i*w)^2+7*i*w+12);
f4=ifourier(F4,t);
disp('the inverse fourier transform of (3*i*w+14)/((i*w)^2+7*i*w+12)=');
disp(f4);
RESULT: - Thus the MATLAB program to find Fourier transform and inverse Fourier transform
of given functions has been executed successfully.
OUTPUT:-
the fourier transform of dirac(t) =1
31
Signals and Systems Lab
Experiment no-10(b)
MAGNITUDE AND PHASE SPECTRUM OF FOURIER TRANSFORMS
AIM: -. To find Fourier transform of the given signal and to plot its magnitude and phase spectrum.
SOFTWARE REQURIED :-
MATLAB R2010a
. PROCEDURE:-
Open MATLAB
Open new M-file
Type the program
Save in current directory
Compile and Run the program
For the output see command window\ Figure window
PROGRAM:-
clc; clear all; close all;
syms t s ;
syms w float;
f=3*exp(-t)*heaviside(t); % given function
F=fourier(f); % to find Fourier Transform
disp('the fourier transform of 3*exp(-t)*u(t) =');
disp(F); % to display the result in the command window
w=-2*pi:pi/50:2*pi;
F1=subs(F,w); % substitute w in F function
Fmag=abs(F1); % to find magnitude
Fphas=angle(F1); % to find phase
subplot(2,1,1);
plot(w,Fmag);
xlabel('w ---->');
ylabel('Magnitude --->');
title('Magnitude spectrum');
grid;
subplot(2,1,2);
plot(w,Fphas);
xlabel('w ---->');
ylabel('Phase in radians--->');
title('Phase spectrum');
grid;
RESULT: - Thus MATLAB program to find Fourier transform and to plot its magnitude and Phase
spectrums has been executed successfully.
32
Signals and Systems Lab
OUTPUT:-
33
Signals and Systems Lab
Experiment no-11
LAPLACE TRANSFORM
AIM: -. MATLAB program to plot the given waveform using waveform synthesis method by
applying Laplace transform.
SOFTWARE REQURIED :-
MATLAB R2010a
.
PROCEDURE:-
Open MATLAB Software
Open new M-file
Type the program
Save in current directory
Run the program
For the output see command window\ Figure window.
PROGRAM:-
clc;
close all;
syms s;
F =(1/(s^2))*(1-exp(-s)-(1/2)*exp(-3*s)+(1/2)*exp(-5*s));
f=ilaplace(F);
pretty(simplify(f))
ezplot(f,[0,5]);
grid;
RESULT: - Thus the MATLAB program to plot waveform using waveform synthesis method and
applying Laplace Transform has been executed successfully.
34
Signals and Systems Lab
OUTPUT:-
35
Signals and Systems Lab
Experiment No-12(a)
SOFTWARE REQURIED :
MATLAB R2010a
.
PROCEDURE:-
Open MATLAB Software
Open new M-file
Type the program
Save in current directory
Run the program
For the output see command window\ Figure window.
PROGRAM:-
clc; clear all; close all;
num=input('enter the numerator polynomial vector\n'); % [1 -2 1]
den=input('enter the denominator polynomial vector\n'); % [1 6 11 6]
H=tf(num,den)
[p z]=pzmap(H);
disp('zeros are at ');
disp(z);
disp('poles are at ');
disp(p);
pzmap(H);
if max(real(p))>=0
disp(' All the poles do not lie in the left half of S-plane ');
disp(' the given LTI systen is not a stable system ');
else
disp('All the poles lie in the left half of S-plane ');
disp(' the given LTI systen is a stable system ');
end;
RESULTS: - Thus the MATLAB program to draw pole-zero map in S-plane has been executed
successfully.
OUTPUT:-
36
Signals and Systems Lab
Transfer function:
s^2 - 2 s + 1
----------------------
s^3 + 6 s^2 + 11 s + 6
Zeros are at
1
1
Poles are at
-3.0000
-2.0000
-1.0000
37
Signals and Systems Lab
Experiment no-12(b)
PROGRAM:-
RESULTS: - Thus the MATLAB program to draw pole-zero map in S-plane has been executed
successfully.
38
Signals and Systems Lab
OUTPUT:-
Enter the numerator polynomial vector
[1 0 0]
Enter the denominator polynomial vector
[1 1 0.16]
Transfer function:
1
--------------------
1 + z^-1 + 0.16 z^-2
39
Signals and Systems Lab
Experiment no-13
GAUSSIAN NOISE
AIM: -. To generate a Gaussian noise and to compute its Mean, Mean Square Value, Skew,
Kurtosis and to plot Probability Density function.
SOFTWARE REQURIED :-
MATLAB R2010a
.
PROCEDURE:-
Open MATLAB Software
Open new M-file
Type the program
Save in current directory
Run the program
For the output see command window\ Figure window.
PROGRAM:-
40
Signals and Systems Lab
RESULTS: - Thus Matlab program to generate Gaussian noise and to compute its Mean, Mean
Square Value, Skew, Kurtosis and to plot its Probability density function has been executed
successfully.
OUTPUT:-
Mean = 9.2676e-004
STD = 0.9889
Var = 0.9780
Skew = -0.0091
Kurt = 2.9520
41
Signals and Systems Lab
Experiment No-14
SAMPLING THEOREM
PROGRAM:-
clc;
close all;
clear all;
f1=3;
f2=20;
t=-0.4:0.0001:0.4;
x=cos(2*pi*f1*t)+cos(2*pi*f2*t);
figure(1);
plot(t,x,'-.r');
xlabel('time-----');
ylabel('amp---');
title('The original signal');
%case 1: (fs<2fm)
fs1=1.4*f2;
ts1=1/fs1;
n1=-0.4:ts1:0.4;
xs1=cos(2*pi*f1*n1)+cos(2*pi*f2*n1);
figure(2);
plot(n1,xs1);
hold on;
plot(t,x,'-.r');
hold off;
legend('fs<2fm');
%case 2: (fs=2fm)
fs2=2*f2;
ts2=1/fs2;
n2=-0.4:ts2:0.4;
xs2=cos(2*pi*f1*n2)+cos(2*pi*f2*n2);
42
Signals and Systems Lab
figure(3);
plot(n2,xs2);
hold on;
plot(t,x,'-.r');
hold off;
legend('fs=2fm');
%case 3: (fs>2fm)
fs3=8*f2;
ts3=1/fs3;
n3=-0.4:ts3:0.4;
xs3=cos(2*pi*f1*n3)+cos(2*pi*f2*n3);
figure(4);
plot(n3,xs3);
hold on;
plot(t,x,'-.r');
hold off;
legend('fs>2fm');
RESULTS:- Thus the MATLAB program to verify Sampling theorem has been executed
successfully.
43
Signals and Systems Lab
OUTPUT : -
44
Signals and Systems Lab
45
Signals and Systems Lab
Experiment no-15
AUTO-CORRELATION/CROSS-CORRELATION
AIM: -. To write a program to detect the periodic signal by Noise using Auto correlation and Cross
Correlation method.
PROGRAM:-
clc;
clear all;
close all;
t=0:0.01:10;
s=cos(2*pi*3*t)+sin(2*pi*5*t); % periodic signal
figure;
subplot(2,1,1);
plot(t,s);
axis([0 10 -2 2]);
xlabel(' t ---->'),ylabel(' amp ----> ');
title('the periodic signal');
L=length(t);
n=randn(1,L); % noise signal
subplot(2,1,2);
plot(t,n);
xlabel(' t ---->'),ylabel(' amp ----> ');
title('the noise signal');
L=length(t);
f=s+n; % received signal
figure;
subplot(2,1,1);
plot(t,f);
xlabel(' t ---->'),ylabel(' amp ----> ');
title('the received signal');
rxx=xcorr(f,s,200);
subplot(2,1,2);
plot(rxx);
title('the Correlator output');
46
Signals and Systems Lab
RESULTS: - Thus the MATLAB Program to detect the periodic signal masked by noise using
Auto Correlation and Cross Correlation method has been executed successfully.
OUTPUT
47
Signals and Systems Lab
48