Signal and Sytem Lab #1
Signal and Sytem Lab #1
Signal and Sytem Lab #1
Lab Title:
Aim of Experiment:
The Experiment aims to familiarize with the Matlab environment and running some
Theory:
hundreds of built-in functions for technical computing, graphics, and animations. Some
scientific use, modeling and simulating data, analyzing data. MATLAB is a modern
programming language environment, and it has refined data structures, includes built-in
Lab Work:
Coding:
>>a= [2 2 2 2 2 2; 3 3 3 3 3 3; 4 4 4 4 4 4; 5 5 5 5 5 5; 6 6 6 6 6 6; 7 7 7 7 7]
Results:
Page | 1
Generate a 6X1 Matrix:
Coding:
>>b= [3; 4; 5; 6; 7; 8]
Results:
Coding:
>>c= [3 4 5 6; 1 2 3 4; 6 7 8 9]
Results:
Page | 2
| |
1.1 0.0 2.1 −3.5 6.0
0.0 1.1 −6.6 2.8 r . no
1.1 0.1 0.3 −0.4 1.3
r . no 5.1 0.0 1.1 r . no
Where r.no is roll number so my roll number is 1 after putting my roll number in the
matrix will be:
| |
1.1 0.0 2.1 −3.5 6.0
0.0 1.1 −6.6 2.8 1
1.1 0.1 0.3 −0.4 1.3
1 5.1 0.0 1.1 1
Coding:
Results:
Page | 3
2. What is the value of the matrix (4, 1)?
Coding:
>> d (4, 1)
Results:
Page | 4
4. What is the size and Value of the matrix ([1 3], end)?
Coding:
>> f=d ([1 3], end)
>> [m, n] =size (f)
Results:
Page | 5
Determine the size and contents of the following arrays. Note that the
this exercise?
(i). A=1:2:5
The size of the array is 1×3 and the contents are 1, 3 and 5
Coding:
>> A=1:2:5;
Page | 6
>> disp (B)
Results:
Page | 7
>> [m, n] =size (D)
Coding:
Results:
Page | 8
(vi).B ([1 3], 2) = B ([3 1], 2)
Coding:
Results:
Assume that value has been initialized to (r.no)*pi and determine what
My roll number is 1
Coding:
Page | 9
Results:
Coding:
Coding:
Coding:
Page | 10
>> fprintf ('value=%f\n', value);
Results:
Coding:
>> r.no=1;
>> a=r.no/5+6;
Results:
(b)(r.no/5)+6
My roll number is 1
Coding:
>> r.no=1;
>> b= (r.no/5) +6;
>> disp (b)
Page | 11
Results:
Coding:
>> r.no=1;
>> c=r.no / (5+6);
>> disp (c)
Results:
Coding:
>> r.no=1;
>> d=r.no ^2^3;
>> disp (d)
Results:
Page | 12
(e). (r.no ^2) ^3
Coding:
>>r.no=1;
>>e= (r.no^2) ^3;
>>disp (e)
Results:
Coding:
>> r.no=1;
>> f=r.no ^ (2^3);
>> disp (f)
Results:
Page | 13
Coding:
>> r.no=1;
>> g=round (-11/5)+6;
>> disp (g)
Results:
Coding:
>> r.no=1;
>> h=ceil (-11/5) +6;
>> disp (h)
Results:
Coding:
>> r.no=1;
>> i=floor (-11/5) +6;
>> disp (i)
Results:
Page | 14
Page | 15
LAB SESSION#2
Lab Title:
“Programming in MATLAB”
Aim of Experiment:
create matrix, different functions in Matlab, basics of plotting and formatting graphs in
Theory:
hundreds of built-in functions for technical computing, graphics, and animations. Some
scientific use, modeling and simulating data, analyzing data. MATLAB is a modern
programming language environment, and it has refined data structures, includes built-in
Lab Work:
Suppose that u=r.no and v=r.no+5. Plot the following expressions using
(a) 4u/3v
(b) 2v-2/(u+v)2
Page | 1
(c) v3/v3-u3
(d) 4/3 pi.v2
Coding:
>>clear all
>>close all
>>u =1;
>>v=u+5;
>>subplot (2, 2, 1)
>>xlabel ('-----u-----')
>>ylabel ('-----v-----')
>>hold on
>>x=2*v^ (-2);
>>subplot (2, 2, 2)
>>xlabel ('-----x=2*v^2-----')
>>x= v^3;
>>subplot (2, 2, 3)
Page | 2
>>plot (x, y,’g: o')
>>xlabel('-----u=v^3-----')
>>ylabel ('-----v=v^3 - u^3-----')
>>title ('plot # 3')
>>hold on
>>x=4;
>>y= 3* 3.14 * v^2;
>>subplot (2, 2, 4)
>>plot (x, y,’g :+')
>>xlabel('-----u=4-----')
>>ylabel ('-----v=3* 3.14 * v^2-----')
>>title ('plot # 4')
Graph:
Page | 3
Coding:
>>clear all
>>close all
>>t=5:25;
>>x (t) = -0.1*t. ^4 + 0.8*t. ^3 + 10*t - 1
>>plot (x (t), y,’g--o')
>>xlabel('----x(t)----')
>>ylabel ('----t----')
>>title ('GRAPH')
Graph:
derivatives,-2≤x≤4, all in the same plot. Use hold and legend commands and
Coding
>>clear all
>>close all
>>x = -2:4;
>>y = 3*x. ^3-26.*x + 1;
>>subplot (2, 2, 1)
Page | 4
>>plot (x, y,’g :*')
>>xlabel('-----x-----')
>>ylabel ('-----y-----')
>>title ('function')
>>hold on
>>y2=9*x. ^2 -26;
>>subplot (2, 2, 2)
>>plot (x, y2,’b :*')
>>xlabel('-----x-----')
>>ylabel ('-----y2-----')
>>title ('first derivative')
>>hold on
>>y3 = 18*x;
>>subplot (2, 1, 2)
>>plot(x, y3,'r: o')
>>xlabel('-----x-----')
>>ylabel ('-----y3-----')
>>title ('second derivative')
Graph:
Page | 5
Coding:
>>clear all
>>close all
>>x=0:2*pi;
>>r= 3*cos(x/2). ^2 + x;
>>plot(x, r)
>>xlabel ('-----x= theta-----')
>>ylabel ('-----r-----')
>>title ('function graph')
Graph:
Coding:
>>clear all
>>close all
>>x=0: pi/10:2*pi;
>>a = sin(x);
>>y = cos (2*x);
Page | 6
>> Plot (a, y,’g :+')
>> xlabel ('-----sin(x)-----')
>> Ylabel ('-----cos (2x) -----')
>>title ('function graph')
Graph:
Page | 7
Page | 8
LAB SESSION#3
Lab Title:
Aim of Experiment:
basic signals i.e. Continuous and Discrete. The experiment also aims to study
Theory:
uncountable or infinite set of numbers in its sequence. The continuous-time signal can be
represented and defined at any instant of the time in its sequence. The continuous-time
signal is also termed as analog signal. It is a continuous function of time defined on the
real line (or axis) R. It has continuous amplitude and time. That is, the continuous-time
signals will have certain value at any instant of time. Discrete-time signal is the
“function of discrete-time variable that has countable or finite set of numbers in its
sequence”. The discrete-time signal can be represented and defined at certain instants of
time in its sequence. That is, the discrete-time signal is able to define only at the sampling
instants. Digital signal can be obtained from the discrete-time signal by quantizing and
encoding the sample values. The discrete-time signals are represented with binary bits
and stored on the digital medium. A signal which is symmetrical about the vertical axis
or time origin is known as even signal or even function. Therefore, the even signals are
also called the symmetrical signals. Cosine wave is an example of even signal. A signal
Page | 1
that is anti-symmetrical about the vertical axis is known as odd signal or odd function.
Therefore, the odd signals are also called the antisymmetric signals. Sine wave is an
Lab Work:
Lab-3a:
Book: Signal & Systems
Author: Alan V. Oppenheim
Edition: Second
Page: 57
Question: 1.3 a, c, d, f
Page | 2
c. x3(t)=cos(t)
>>close all
>>clear all
>>t=0:0.5:10;
>>x3=cos (t);
>>subplot (2, 2, 1)
>>plot (t, x3);
>>xlabel ('X')
>>ylabel ('y')
>>title ('continuous signal')
>>hold on;
>>subplot (2, 2, 2)
>>stem (t, x3)
>>xlabel ('x')
>>ylabel ('y')
>>title ('discrete')
Graph:
>>close all;
Page | 3
>>clear all;
>>n=0:0.5:5;
>>x= (1/2). ^n;
>>subplot (2, 2, 1)
>>plot (n, x);
>> xlabel ('x')
>>ylabel ('y')
>>title ('continuous signal')
>>subplot (2, 2, 4)
>>stem (n, x);
>>xlabel ('x')
>>ylabel ('y')
>>title ('discrete signal')
Graph:
f. x3[n]=cos(Π/4
Coding:
>>close all;
>>clear all;
>>n=1:0.1:2;
>>pi=3.14;
>>x=cos (pi/4*n);
>>subplot (2, 1, 1)
>>plot (n, x)
>>title ('continues signal')
>>xlabel ('n')
>>ylabel ('x')
>>subplot (2, 1, 2)
>>stem (n, x)
>>title ('discrete signal')
>>xlabel ('n')
>>ylabel ('x')
Graph:
Page | 4
Lab-3b:
Book: Signal & Systems
Author: Alan V. Oppenheim
Edition: Second
Page: 57, 60, 61
Question: 1.7 b, 1.23 a, 1.24 c,
Plot these signals with their even and odd part. Also determine that the given signal
is even or odd?
Question: 1.7 b:
x2(t) =sin (1/2*t)
Coding:
>>clear all;
>>close all;
>> t=0:0.001:4*pi;
>> %defining functions
>> x1=sin (t/2);
>> x2=sin(-t/2);
>> %checking even or odd
>> If(x1==x2)
>> disp ('Even')
>> else
>> If(x1==-x2)
>> disp (‘odd')
>> else
>> disp ('neither even nor odd')
>> end
>> end;
>> figure
Page | 5
Question 1.23 a
Determine and sketch the even and odd parts of the signals depicted in
Figure Pl.23.Label your sketches carefully.
>>clear all;
>>close all;
>>t=-2:1:2;
>>%defining function
>>x1=zeros (size (t));
>>x2=zeros (size (t));
>>x1(4) =1;
>>x2(2) =1;
>>%checking even or odd
>>if(x1==x2)
>>disp ('Even')
>>else
>>if(x1==-x2)
>>disp (‘odd')
>>else
>>disp ('neither even nor odd')
>>end
>>end;
>>figure
>>%plot original signal
Page | 6
>>subplot (2, 2, 1)
>>plot (t, x1)
>>title ('original signal')
>>xlabel('t')
>>ylabel (‘x (t)')
>>%plot flipped signal
>>subplot (2, 2, 2)
<<plot (t, x2)
>>title ('flipped signal')
>>xlabel ('t')
>>ylabel (‘x (-t)')
>>%plot even signal
>>e=1/2.*(x1+x2);
>>subplot (2, 2, 3)
>>plot (t, e)
>>title ('even signal')
>>xlabel('t')
>>ylabel ('1/2[x (t) +x (-t)]')
>>%plot odd signal
>>o=1/2.*(x1-x2);
<<subplot (2, 2, 4)
>>plot (t, o)
>>title ('odd signal')
>>xlabel('t')
>>ylabel ('1/2[x(t)-x(-t)]')
Question# 1.24 c
Page | 7
Determine and sketch the even and odd parts of the signals depicted in
Figure P 1.24. Label your sketches carefully
>>clear all;
>>close all;
>>t=-5:1:4;
>>x1(1) =0; x1(2) =-1; x1(3) =2; x1(4) =2; x1(5) =1; x1(6) =1; x1(7) =2; x1(8) =1; x1(9) =-1;
>>x1(10) =0;
>>x2(1) =0; x2(2) =0; x2(3) =-1; x2(4) =1; x2(5) =2; x2(6) =1; x2(7) =1; x2(8) =2;
>>x2(9) =2; <<x2(10) =-1;
>>%checking even or odd
>>if(x1==x2)
>>disp ('Even')
>>else
>>if(x1==-x2)
>>disp (‘odd')
>>else
>>disp ('neither even nor odd')
>>end
>>end;
>>figure
>>%plot original signal
>>subplot (2, 2, 1)
>>stem (t, x1)
>>title ('original signal')
>>xlabel('n')
>>ylabel ('x[n]')
>>%plot flipped signal
>>subplot (2, 2, 2)
>>stem (t, x2)
>>title ('flipped signal')
>>xlabel('n')
>>ylabel (‘x [-n]')
>>%plot even signal
>>e=1/2.*(x1+x2);
>>subplot (2, 2, 3)
>>stem (t, e)
Page | 8
>>title ('even signal')
>>xlabel('n')
>>ylabel ('1/2[x[n] +x [-n]]')
>>%plot odd signal
>>o=1/2.*(x1-x2);
>>subplot (2, 2,4)
>>stem (t, o)
>>title ('odd signal')
>>xlabel ('n')
>>ylabel ('1/2[x[n]-x [-n]]')
Page | 9
Page | 10
LAB SESSION#4
Lab Title:
This experiment aims to study the transformations of the Time Variable for
Theory:
either t−t0 or t+t0 . Here t0 is called as the shifting factor. Shifting in time may results in
time delay or time advancement. A signal x (t) may be scaled in time by replacing the
independent variable t by at. Here ‘a’ is called as the scaling factor. Time scaling may
by ‘−t’, this operation is known as time reversal of the signal about the y-axis or
amplitude axis. This can be achieved by taking mirror image of the signal x(t) about y-
axis or by rotating x(t) by 180° about y-axis. Hence, time reversal is known
as folding or reflection.
Lab Work:
1
1. Question: 1.23 (b, c), 1.22 (g) (shift and scale the signals by )
Roll no
2. Plot original, shifted, scaled and flipped version of signals.
Page | 1
Question 1.22(g)
Page | 2
>> Title ('Scaled Signal by 1/1')
Page | 3
>> title('x(t)')
%Defining and plotting The Flipped Version the Required Signal
>> subplot(2,2,2)
>> Plot (-t,x)
>> title ('x(-t)')
%defining and plotting The Shifted Version of the Required Signal
>> Subplot (2, 2, 3)
>> plot (t+1,x)
>> title('x(t+1)')
%defining and plotting The Scaled Version of the Required Signal
>> subplot(2,2,4)
>> plot(t.*(1),x)
>> title('x(1t)')
Page | 4
>> title ('x(-t)')
%plotting the shifted signal
>> plot (t+(1),x,’g')
>> title ('x[t-1]')
%plotting the scaled signal
>> subplot (2,2,4)
>> plot (t.*(1),x)
>> title ('x[t.*(1)]')
Page | 5
Page | 6
Page | 7
LAB SESSION#5
Lab Title:
This experiment aims to learn discrete time and continuous time convolution of signals.
Theory:
Convolution is a mathematical tool for combining two signals to produce a third signal.
In other words, the convolution can be defined as a mathematical operation that is used
to express the relation between input and output an LTI system. Consider two
signals x1(t) and x2(t). Then, the convolution of these two signals is defined as
Lab Work:
• Book: Signal & Systems
• Author: Alan V. Oppenheim
• Edition: Second
• Page: 138, 141, 144
• Question: 2.4, 2.21 c, 2.25
• Plot x[n], h[n] and y[n].
Code:
>> close all
>> clear all
%Question # 2.4
% Defining x-axis
Page | 1
>>n= [0:20]
>>x1=1
>>x2=0
%Defining First signal
>>x=x1*(n>=3 & n<=8) + x2*(n<=3 & n>=8)
>> Subplot (3, 1, 1)
>> stem (n,x,'blue')
>>title('x[n]')
>>h=x1*(n>=4 & n<=15) + x2*(n<=4 & n>=15)
>>subplot(3,1,2)
>>stem (n,h,'k')
>>title ('h[n]')
%Calculating Convolution and plotting the result
>>y1=conv(x,h)
>>L=length (y1)
>>n=[0:L-1]
>>subplot (3, 1, 3)
>>stem (n, y1,'red')
>>title ('x[n]*h[n]')
Code:
>>close all
>>clear all
%Question No#2.21c
Page | 2
>>n= [-5:20]
>>x1=1
>>x2=0
%defining first signal
>>u1 = x1*(n>=4) + x2*(n<4)
>>signal1= ((-1/2). ^n).*u1;
>>subplot (2, 2,1)
>>stem (n, signal1,'blue')
>>title ('x1[n]')
%defining Second signal
>>u2 = x1*(n>=2) + x2*(n<2)
>>signal2=(4.^n).*u2
>>subplot (2,2,2)
>>stem (n, signal2, ‘k’)
>>title ('h[n]')
%Calculating Convolution and plotting the result
>>y1=conv(signal1,signal2)
>>L=length(y1)
>>n=[0:L-1]
%plotting the Convolved signal
>>subplot (2, 2, 3)
>>stem (n, y1,'red')
>>title ('x[n] * h[n]')
Page | 3
Code:
>>close all
>>clear all
%===========
%Question No#2.25
>>n= [-10:10]
>>x1=1
>>x2=0
%defining first signal
>>u0 = x1*(n>=0) + x2*(n<0) %unit step Function
>>u1=x1*(n<=-1) + x2*(n>-1) %For u[-n-1]
>>signal1=((3.^n).*u1)+(((1/3).^n ).*u0 );
>>subplot(2,2,1)
>>stem(n,signal1,'blue')
>>title('x[n]')
%defining Second signal
>>u2 = x1*(n>=-3) + x2*(n<-3) %for u[n+3]
>>signal2=((1/4).^n).*u2
>>subplot(2,2,2)
>>stem(n,signal2,'k')
>>title('h[n]')
%Calculating Convolution and plotting the result
>>y1=conv(signal1,signal2)
>>L=length(y1)
>>n=[0:L-1]
%plotting the Convolved signal
>>subplot(2,2,3)
>>stem (n,y1,'red')
>>title ('x[n] * h[n]')
Page | 4
Page | 5
Page | 6
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
>>close all;
>>n=-1:1:10;
Page | 1
>>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 | 2
>>if y1==y2
>>else
>>end
• Coding:
>>close all;
>>n=-1:1:10;
>>h=n.*heaviside (n+2);
Page | 3
>>d=input('Enter the Delay:');
>>y=conv(x, h);
>>figure;
>>xlabel ('n');
>>ylabel ('amp');
>>xlabel ('n');
>>ylabel ('amp');
>>figure;
>>xlabel ('n');
>>ylabel ('amp');
Page | 4
>>stem (0: length (ydn) -1,ydn);
>>xlabel ('n');
>>ylabel ('amp');
>>if yn==yndn
>>else
>>end
Page | 5
Question 2.4:
• Coding:
>>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);
Page | 6
>>stem (n, y2);
>>xlabel ('n');
>>ylabel ('amp');
>>title ('Total Responses');
>>if y1==y2
>>disp ('System is Linear');
>>else
>> disp ('System is Non-Linear');
>>end
Result:
Graph:
Page | 7
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 | 8
>>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 | 9
Page | 10
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 | 1
>>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 | 2
>>x label ('n')
>>y label ('y2')
>>title ('auto co-relation signal')
Page | 3
Page | 4
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 | 1
>>h = ilaplace (H);
>>simplify (h)
>> Y = (1/s)*((1/(s+1))+(1/(s+3)));
>> y = ilaplace(Y);
>> simplify(y)
>> t = 0:0.1:20;
Page | 2
Coding (b) part
>>clear all
>>figure;
>>simplify (h);
>>disp (h)
>>t=.1:1:20;
>>subplot (2, 1, 1)
Page | 3
>>u=1/s*H % step response of H
>>h2=subs (u, t)
>>subplot (2, 1, 2)
>>plot (h2,'g--')
Page | 4
>>u=1/s*H
% step response of H
>>h2=subs (u, t)
>>subplot (2, 1, 2)
>>plot (h2,'g--')
>>title ('step response')
Page | 5
Page | 6
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 | 1
>>disp (F3);
>>f4=sin (0*t);
>>F4=fourier (f4);
>>disp ('The fourier transform of sin (0*t) is');
>>disp (F4);
>>figure
Result:
Result:
Page | 2
Page | 3
Page | 4
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 | 1
Result:
Page | 2
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 | 1
Page | 2
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 | 1
>>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 | 2
>>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 | 3
Page | 4
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 | 2
Page | 3
Page | 4
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 | 1
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-
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 | 2
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 | 3