Moeed Signal Manuals 6-14
Moeed Signal Manuals 6-14
Moeed Signal Manuals 6-14
LAB SESSION # 06
By
Date: 28-12-2022
University of Gujrat
Session 2020-24
LAB SESSION#6
Lab Title:
This laboratory experiment aims to learn different properties of LTI systems i.e.
Linear/Non-Linear/Time Invariant/Time variant.
Theory:
Linear time-invariant systems (LTI systems) are a class of systems used in signals and
systems that are both linear and time-invariant. Linear systems are systems whose
outputs for a linear combination of inputs are the same as a linear combination of
individual responses to those inputs. Time-invariant systems are systems where the
output does not depend on when an input was applied.
Lab Work:
Book: Signal & System by Alan V. Oppenheim Second edition
Coding
>>close all;
>>n=-1:1:10;
Page | 2
>>xlabel ('n');
>>ylabel ('amp');
>>title ('x1[n]');
>>h=n.*heaviside(n+2);
>>y1=y01+y02;
>>n=0: L-1;
>>xlabel ('n');
>>ylabel ('amp');
>>xlabel ('n');
>>ylabel ('amp');
Page | 3
>>if y1==y2
>>else
>>end
• Coding:
>>close all;
>>n=-1:1:10;
>>h=n.*heaviside (n+2);
Page | 4
>>d=input('Enter the Delay:');
>>y=conv(x, h);
>>figure;
>>xlabel ('n');
>>ylabel ('amp');
>>xlabel ('n');
>>ylabel ('amp');
>>figure;
>>xlabel ('n');
>>ylabel ('amp');
Page | 5
>>stem (0: length (ydn) -1,ydn);
>>xlabel ('n');
>>ylabel ('amp');
>>if yn==yndn
>>else
>>end
Question 2.4:
• Coding:
Page | 6
>>close all;
>>n= [0:1:10];
>>a=input ('Enter the constant a');
>>b=input ('Enter the constant b');
>>n1 = 1;
>>n2 = 0;
%for First Signal;
>>x1=3.*cos ((4*n) + (pi/3));
>>subplot (2, 2, 1);
>>stem (n, x1);
>>xlabel ('n');
>>ylabel ('amp');
>>title ('x1[n]');
%for Second Signal;
>>x2=n1*(n>=3 & n<=8) + n2 (n<=3 & n>=8);
>>subplot (2, 2, 2);
>>stem (n, x2);
>>xlabel ('n');
>>ylabel ('amp');
>>title ('x2[n]');
%for Impulse Response Signal;
>>h=n1*(n>=4 & n<=15) + n2*(n<=4 & n>=15);
>>subplot (2, 2, 3:4);
>>stem (n, h)
>>xlabel ('n');
>>ylabel ('amp');
>>title ('h[n]');
>>figure;
%for Linearity and Non -Linearity
>>y01= conv (a*x1, h);
>>y02= conv (b*x2, h);
>>y1=y01+y02;
>>x= (a.*x1) + (b.*x2);
>>y2= conv(x, h);
>>L=length(x) +length (h) -1;
>>n=0: L -1;
>>subplot (2, 2, 1:2);
>>stem (n, y1);
>>xlabel ('n');
>>ylabel ('amp');
>>title ('Sum of Individual Responses');
>>subplot (2, 2, 3:4);
>>stem (n, y2);
>>xlabel ('n');
Page | 7
>>ylabel ('amp');
>>title ('Total Responses');
>>if y1==y2
>>disp ('System is Linear');
>>else
>> disp ('System is Non-Linear');
>>end
Result:
Graph:
Page | 8
Coding for Question 2.4:
• For Time Invariance and Time Variance:
%for Time Invariance and Time Variance;
>>close all;
>>n=-1:1:10;
>>n1 = 1;
>>n2 = 0;
>>x = n1*(n>=3 & n<=8) + n2*(n<=3 & n>=8);
>>h=n1*(n>=4 & n<=15) + n2*(n<=4 & n>=15);
>>d=input ('Enter the Delay :');
>>xdn= [zeros (1, d), x];
>>yn=conv (xdn, h);
>>y=conv(x, h);
>>ydn= [zeros (1, d), y];
>>figure;
>>subplot (2, 1, 1);
>>stem (0: length(x)-1, x);
>>xlabel ('n');
>>ylabel ('amp');
>>title ('sequence of x[n]');
>>subplot (2, 1, 2);
>>stem (0: length (xdn)-1, xdn);
>>xlabel ('n');
>>ylabel ('amp');
>>title ('Delayed Sequence of x[n]');
>>figure;
>>subplot (2, 1, 1);
Page | 9
>>stem (0: length(y)-1, y);
>>xlabel ('n');
>>ylabel ('amp');
>>title ('sequence of y[n]');
>>subplot (2, 1, 2);
>>stem (0: length (ydn)-1, ydn);
>>xlabel ('n');
>>ylabel ('amp');
>>title ('Delayed Sequence of y[n]');
>>if yn==yndn;
>>disp ('System is Time Invariant');
>>else
>>disp ('System is Time Variant');
>>end
Page | 10
SIGNAL & SYSTEMS LAB (EE-384)
LAB SESSION # 07
By
Date: 04-01-2023
University of Gujrat
Session 2020-24
LAB SESSION#7
Lab Title:
This laboratory experiment aims how to find the auto-correlation and cross-correlation
between signals.
Theory:
Lab Work:
(a) X1(t) = e-2t u (t) (c) X3(t) = cos (t) (d) X1(n) = (½) n u (n) (f) X3(t) = cos (n)
Code:
%Question No (1.3 part (a and c)
>>close all
>>clear all
>>t=0:0.1:10
>>u=heaviside (t)
>>e=2.73
%signal in part (a)
>>x1=e. ^ (-2.*t).*u
>>subplot (2, 2, 1)
>>plot (t, x1)
>>title ('x1(t)')
>>xlabel ('t')
>>ylabel ('e^ (-2t)')
%second signal in part (c)
>>x3=cos (t)
Page | 2
>>subplot (2, 2, 2);
>>plot (t, x3)
>>title ('x3(t)');
>>xlabel ('t');
>>ylabel (‘cos (t)')
%xcorrfuncton co-relate the two signals
>>y1=x corr(x1, x3)
>>subplot (2, 2, 3);
>>plot (y1);
>>title ('Cross Co-Related Signal');
>>xlabel ('t');
>>ylabel ('y1')
%auto co-relation
>>y2=x corr(x1)
>>subplot (2, 2, 4)
>>stem (y2)
>>title ('auto co-relation')
>>xlabel ('t')
>>ylabel ('y2')
%Part d and f
%co-relation of signals
>>figure
>>n=0:1:20
>>u=heaviside (n)
>>stem (u)
%signal part d
>>x1= (1/2). ^ (n).*u
>>subplot (2, 2, 1)
>>stem (n, x1)
%signal part f
>>x3=cos (45*n)
>>subplot (2, 2, 2)
>>stem(x3)
%crosses co-relation
>>y1=x corr(x1, x3)
>>subplot (2, 2, 3)
>>stem (y1)
>>xlabel ('n')
>>ylabel ('y1')
>>title ('cross co-relation')
%auto co-relation
>>y2=x corr(x1)
>>subplot (2, 2, 4)
>>stem (y2)
Page | 3
>>x label ('n')
>>y label ('y2')
>>title ('auto co-relation signal')
Page | 4
SIGNAL & SYSTEMS LAB (EE-384)
LAB SESSION # 08
By
Date: 18-01-2023
University of Gujrat
Session 2020-24
LAB SESSION#8
Lab Title:
This laboratory experiment aims at how to find the Impulse response and step response of
LTI systems.
Theory:
A system for which the principle of superposition and the principle of homogeneity are
valid and the input/output characteristics do not change with time is called the linear
time-invariant (LTI) system. When the impulse signal is applied to a linear system, then
the response of the system is called the impulse response. The convolution integral can
be used to obtain the step response of a continuous-time LTI system.
Lab Work:
Signal & Systems by Alan V. Oppenheim (2nd edition)
Page # 721 Qs: 9.5 a, b, c and Plot impulse response and step response of these questions.
Coding:
>>close all
>>syms s complex
Page | 2
>> disp ('Impulse response of system is')
>>simplify (h)
>> y = ilaplace(Y);
>> simplify(y)
>> t = 0:0.1:20;
Page | 3
Coding (b) part
>>clear all
>>figure;
>>simplify (h);
>>disp (h)
>>t=.1:1:20;
>>subplot (2, 1, 1)
Page | 4
>>u=1/s*H % step response of H
>>h2=subs (u, t)
>>subplot (2, 1, 2)
>>plot (h2,'g--')
Coding(c) part:
>>clear all
>>syms s complex
% symbolic variable created here it is complex, it can be real
>>H= ((s. ^3)-1/ (s. ^2+s+1))
%system
>>h= ilaplace (H)
%inverse laplace
>>figure;
>>simplify (h);
>>disp (h)
>>t=.1:1:20;
>>h1=subs (h, t)
%substitution
>>subplot (2, 1, 1)
>>plot (t, h1,'c--')
Page | 5
>>title ('impulse response')
>>u=1/s*H
% step response of H
>>h2=subs (u, t)
>>subplot (2, 1, 2)
>>plot (h2,'g--')
>>title ('step response')
Page | 6
SIGNAL & SYSTEMS LAB (EE-384)
LAB SESSION # 09
FOURIER SERIES
By
Date: 25-01-2023
University of Gujrat
Session 2020-24
LAB SESSION#9
Lab Title:
“Fourier Series”
Aim of Experiment:
The aim of this experiment is to find the Fourier and inverse Fourier transforms.
Theory:
Fourier series simply states that, periodic signals can be represented into sum of sines and
cosines when multiplied with a certain weight. The Fourier transform simply states that
that the non periodic signals whose area under the curve is finite can also be represented
into integrals of the sines and cosines after being multiplied by a certain weight.
The inverse Fourier transform is a mathematical formula that converts a signal in the
frequency domain ω to one in the time (or spatial) domain t.
Lab Work:
For Fourier Transforms
>>close all;
>>clear all;
>>syms t s;
>>syms w real;
>>syms A real;
>>syms b real;
>>syms f floor;
>>f=dirac (t);
>>F=fourier (f);
>>disp (‘the fourier transform of dirac (t) is');
>>disp (F);
>>f1=A*heaviside (t);
>>F1=fourier (f1);
>>disp (‘the fourier transform of A= ');
>>disp (F1);
>>f2=A*exp (-t)*heaviside (t);
>>F2=fourier (f2);
>>disp ('The fourier transform of exp(-t) is');
>>disp (F2);
>>f3=A*t*exp (-b*t)*heaviside (t);
>>F3=fourier (f3);
>>disp (‘the fourier a transform of A*t*exp (-b*t)*4(t) = ');
Page | 2
>>disp (F3);
>>f4=sin (0*t);
>>F4=fourier (f4);
>>disp ('The fourier transform of sin (0*t) is');
>>disp (F4);
>>figure
Result:
Result:
Page | 3
Page | 4
SIGNAL & SYSTEMS LAB (EE-384)
LAB SESSION # 10
By
Date: 01-02-2023
University of Gujrat
Session 2020-24
LAB SESSION#10
Lab Title:
This lab aims to calculate the Magnitude and Phase Spectrum of Fourier Transforms.
Lab Work:
Coding:
>>clear all;
>>close all;
>>syms t s;
>>syms w float;
>>f=3*exp (-t)*heaviside (t);
%given function
>>F=fourier (f);
>>disp (‘the fourier transform of 3*exp (-t)*u (t) =');
>>disp (F);
>>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;
Page | 2
Result:
Page | 3
SIGNAL & SYSTEMS LAB (EE-384)
LAB SESSION # 11
LAPLACE TRANSFORM
By
Date: 15-02-2023
University of Gujrat
Session 2020-24
LAB SESSION#11
Lab Title:
“Laplace Transform”
Aim of Experiment:
This lab aims to find Laplace Transform and inverse Laplace transforms.
Theory:
Laplace transforms permits to go from time domain to frequency domain whereas inverse
Laplace transform allows to go from frequency domain to time domain.
Lab Work:
>>close all;
>>clear all;
>>syms s;
>>f=ilaplace (F);
>>grid;
Results:
Page | 2
Page | 3
SIGNAL & SYSTEMS LAB (EE-384)
LAB SESSION # 12
By
Date: 22-02-2023
University of Gujrat
Session 2020-24
LAB SESSION#12
Lab Title:
This lab aims to study Zeroes and poles in the S-plane, Zeroes and poles in Z-plane.
Theory:
The poles and zeros of a transfer function may be complex, and the system dynamics may
be represented graphically by plotting their locations on the complex s-plane, whose axes
represent the real and imaginary parts of the complex variable s. Such plots are known as
pole-zero plots. It is usual to mark a zero location by a circle (◦) and a pole location a
cross (×).
Lab work:
>>clear all;
>>close all;
>>disp (z);
>>disp (p);
Page | 2
>>if max (real (p))>=0;
>>disp (‘all the poles do not lie in the left half of the S-plane');
>>else
>> disp ('All the poles lie in the left half of S-plane');
>>end;
Result:
Coding
>>clear all;
>>close all;
Page | 3
>>num=input ('Enter the numerator polynomial vector\n');
>>H=filt (num,den)
>>Z=zero (H);
>>disp (Z);
>>disp (p);
>>disp (‘all the poles do not lie within the unit circle');
>>else
>>end;
Result:
Page | 4
Page | 5
SIGNAL & SYSTEMS LAB (EE-384)
LAB SESSION # 13
SAMPLING THEOREM
By
Date: 01-03-2023
University of Gujrat
Session 2020-24
LAB SESSION#13
Lab Title:
“Sampling Theorem”
Aim of Experiment:
Theory:
A continuous time signal can be represented in its samples and can be recovered back
when sampling frequency fs is greater than or equal to the twice the highest frequency
component of message signal. i. e.
f s ≥ 2fm
Lab work:
Page | 3
Page | 4
Page | 5
SIGNAL & SYSTEMS LAB (EE-384)
LAB SESSION # 14
SIMULINK
By
Date: 08-03-2023
University of Gujrat
Session 2020-24
LAB SESSION#14
Lab Title:
“Simulink”
Aim of Experiment:
Theory:
Simulink is a simulation and model-based design environment for dynamic and
embedded systems, integrated with MATLAB. Simulink, also developed by Math Works,
is a data flow graphical programming language tool for modeling, simulating and
analyzing multi-domain dynamic systems. It is basically a graphical block diagramming
tool with customizable set of block libraries. It allows you to incorporate MATLAB
algorithms into models as well as export the simulation results onto MATLAB for further
analysis. Simulink supports the following tasks:
1. System-level Design.
2. Simulation
3. Automatic Code Generation
4. Testing and Verification of Embedded Systems
Starting up SIMULINK
In order to use SIMULINK, you must first start MATLAB. With MATLAB running,
Click the SIMULINK icon on the MATLAB toolbar and Type ‘SIMULINK’ at
Page | 2
Basic Elements:
There are two major categories of elements in Simulink:
1. Blocks
2. Lines
Blocks are used to generate, modify, combine, output, and display signals. Lines, on the
other hand, are used to transfer signals from one block to another.
1. Blocks:
There are several general classes of blocks, some of which are:
Sources: Used to generate various signals. Sources blocks have outputs but no inputs.
One may want to use a Constant input, a Sine Wave, a Step, a Ramp, a Pulse
Generator, or a Uniform Random number to simulate noise. The Clock may be used
Sinks: Used to output or display signals. Sinks blocks have inputs but no outputs.
Discrete: Discrete Filter, Discrete State-Space, Discrete Transfer Fcn, Discrete Zero-
Math Operations: Abs, Gain, Product, Slider Gain, Sign, Sum, etc.
2. Lines:
Lines transmit signal in the direction indicated by the arrow Lines must always transmit
signals from the output terminal of one block to the input terminal of another block .One
Page | 3
exception to this is that a line can tap off of another line. This sends the original signal to
two (or more) destination blocks. Lines can never inject a signal into another line; lines
must be combined through the use of block such as a summing junction. A signal can be
Page | 4