Sie sind auf Seite 1von 43

PAKISTAN NAVY ENGINEERING COLLEGE, NATIONAL UNIVERSITY OF SCIENCES AND

TECHNOLOGY, KARACHI
PNEC NUST

Student Lab Manual

SIGNALS & SYSTEMS


EE-232
Name: ____________________________________________________________________

CMS-ID: _______________________ Class: ____________ Section: _____________

Batch: ________________________ Semester: ________________________________

Department: ________________________________________________________________

EE UG Revised Curricula 2018


DEPARTMENT OF ELECTRONICS & POWER ENGINEERING
Lab Manual Contents

1. Lab Rubrics with Marks Distribution


2. List of Experiments
3. Lab Assessment Record
4. Detailed Experiment Sheets
National University of Sciences & Technology- Pakistan Navy Engineering College

(Group-1): Engineering Lab Rubric

Skill Level
Rubrics BT
Rubrics Indicator Needs Work Developing Competent Exemplary
Code Domain
2.0 3.0 4.0 5.0
Experimental R1 P Ability to gather materials, follow All required materials are Most required materials All required materials are Materials are gathered with
Methods experimental procedure, control not gathered, procedure is are gathered, procedure gathered, selected materials clarity and precision,
variables, present data/ evidence using inadequately followed, could be better are suitable, procedures are procedure is efficiently
charts/ tables/graphs to enable inattentive to safety followed, mostly well followed, and followed, limitations are
comprehension/interpret findings, measures. attentive to safety. limitations are considered, analyzed, demonstrates
compare these values in literature, attentive to safety. exemplary safety.
error analysis, identify limitations and
attentive to comply safety procedures.

☐ ☐
☐ ☐

Tool R2 P Ability to identify, understands, and Demonstrates minimal or no Demonstrates some Demonstrates skillful ability Demonstrates excellent
Handling uses relevant tools to carry out ability to identify or use ability to identify and to identify and use relevant abilityto identify and use
experiment task/activity. tools for an engineering use tools for an tools for an engineering the most relevant tools for
activity. engineering activity. activity. a range of engineering
activities.
☐ ☐ ☐ ☐ ☐

Individual R3 A Ability to carry out individual Rarely performs given task Sometimes performs a Exhibits an ability to Shows an excellent ability
and Team responsibilities, and participate as an individually and no active given task individually perform a given task to perform a given task
Work active team member to accomplish contribution as a team and provides some individually. Provides an individually. Provides
milestones within a specified time. member. Shows poor ability contribution as a team active contribution as a dynamic contribution as a
to manage time. member. Shows little team member to accomplish team member /leader to
ability to manage time. a task in specified time. accomplish a given task
within specified time.
☐ ☐
☐ ☐ ☐
Lab Report R4 A Ability to record and analyze the The required data is not The required data is The required data is The required data is
acquired data, and conclude the recorded and analyzed in the recorded but not properly recorded, analyzed recorded, analyzed and
results in a form of a report. lab report. properly analyzed in the and concluded in the lab concluded in the lab report
lab report. report. with exemplary clarity and
correctness.
☐ ☐ ☐ ☐ ☐
LIST OF EXPERIMENT
BT
Module Topics Book PLO CLOs
Domain
Introduction To Matlab
1

Familiarization With Singularity Functions


2

Basic Operations On Functions & Plotting


3

Convolution
4

Solution Of Differential Equations


5

System Response (Impulse & Step


6
Response)

Laplace Transform & Inverse Laplace


Lab
7 5&9 5&6
Transform Manual A2 & P3

Simulation & Verification Of Control


8
Systems Using Simulink

Fourier Transform & Inverse Fourier


9
Transform

Z Transform & Inverse Ztransform


10

Simple Filter Implementation;


11
Butterworth, Chebychev
Lab Assessment Record

Session: __________________ Lab Venue: _______________________

Course Title CMS ID Student Name Department


EE/ME/IME

Experiment Title/Experiment Marks Obtained Total Teacher


S No Date
Number R1 R2 R3 R4 Marks (20) Initial
1
2
3
4
5

6
7
8
9
10
11
12
13
14
15
16
17
Preface

MATLAB is an environment for performing calculations and simulations of a variety of


types. MATLAB, short for matrix laboratory, was developed by Cleve Moler, a professor of
mathematics and computer science, in the late 70s and early 80s. In 1984, Cleve Moler and
Jack Little founded The MathWorks which has been developing MATLAB ever since. In the
earliest version of MATLAB, there were about 80 commands, and they allowed for matrix
calculations. Now there are thousands of commands, and there are many, many types of
calculations that one can perform. Simulink is a MATLAB \add-on" that allows one to
simulate systems by combining blocks of various types. We will make use of Simulink as
well. During the course of this lab, the student will learn how to make calculations using
MATLAB and will learn a little about simulating systems using the simulation tools
provided by MATLAB and Simulink.
LAB # 01

GENERATION OF BASIC DISCRETE SIGNALS

AIM: - TO write a MATLAB program to generate common discrete time signals


PROCEDURE:- 1

 Open MATLAB 0.9

 Open new M-file 0.8

 Type the program 0.7

 Save in current directory 0.6

 Compile and Run the program


0.5

0.4
 For the output see command window\ Figure window 0.3

0.2

Unit sample (impulse) sequence 0.1

0
-5 -4 -3 -2 -1 0 1 2 3 4 5

0 n0
>>n=-5:5;  [ n]  
>>x=[n==0]; 1 n0
>>stem (n,x)

Unit step sequence

>>n=-5:5; 0 n  0
u[n]  
>>x=[n>=0];
1 n  0
>>stem (n,x)

Unit ramp sequence

>>n=-5:5;
>>x=n.*[n>=0];
>>stem(n,x)

Exponential sequences

>>n=-20:20;
>>x=(0.9.^n).*[n>=0]; x[n]  A n
>>stem(n,x)

Sinusoidal Sequences

>>n=-5:40;
xn  coso n   
>>x=4*cos(0.1*pi*n+pi/3);
>>stem(n,x)
Alternate MATLAB CODE for some basic DT signals:-
clc;
clear all;
close all;

n=0:1:50;
f=input('Enter the value of frequency');
a=input('Enter the value of amplitude');
N=input('Enter the length of unit step');
subplot(3,3,1);

y=a*sin(2*pi*f*n);
stem(n,y,'r');
xlabel('time');
ylabel('amplitude');
title('sine wave')
grid on;
subplot(3,3,2);

z=a*cos(2*pi*f*n);
stem(n,z);
xlabel('time');
ylabel('amplitude');
title('cosine wave')
grid on;
subplot(3,3,3);

s=a*square(2*pi*f*n);
stem(n,s);
xlabel('time');
ylabel('amplitude');
title('square wave')
grid on;
subplot(3,3,4);

stem(n,n);
xlabel('time');
ylabel('amplitude');
title('ramp wave')
grid on;

x=0:N-1;
d=ones(1,N);
subplot(3,3,5);
stem(x,d,'r');
xlabel('time');
ylabel('amplitude');
title('unit step wave')
grid on;

SAMPLE INPUT:-
Enter the value of frequency 0.03
Enter the value of amplitude 1
Enter the length of unit step 9

RESULTS: - Thus the generation of discrete time signals using Matlab has been verified.
POSTLAB:

Q 1: what is signal? Compare continuous & discrete signals. Which one is more convenient? Give your
analysis.

Q 2: Write program in Matlab to generate the following signals:

1. Exponentially damped sinusoidal waveform


2. Saw tooth waveform
3. Triangular pulse
LAB # 02

Basic Operations on DT Signals


AIM: To apply time transformations on DT signals using MATLAB

THEORY:
DT Signals represented as sequences of numbers, called samples. Often times sequences are obtained
by sampling of continuous-time signals. Sample value of a typical signal or sequence denoted as x[n]
with n being an integer in the range -∞ ≤ n ≤∞.

Basic System Operations:

Most of the basic operations are transformations on n, the time variable.


 Time Shifting:
Consider a given signal x (n), which could be as show below:

We can shift this signal along the time axis, like x(n−2)

E.g: Unit sample signal is given by:

Matlab code:

>>n=-5:5;
>>x=[n==0];
>>stem (n,x)

Now applying time shifting:

>>n=-5:5;
>>x=[(n-2)==0];
>>stem (n,x)
 Reversal/folding:
We can flip this signal around the 0 point in time, like x (−n)

Let we have input sequece: x=[2 3 5 4 6 4];


6

for x[n]:
5

n=-2:3;
stem(n,x); 4

for x[-n]:
1

n=-n;
stem(n,x); 0
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2 2.5 3

0
-3 -2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2

 Time Scaling (n)


By changing the time scale, we can increase or decrease the number of samples we’re dealing with.
Down Sampling:
When down sampling, we have a case such as x (n) →x(3n). This will
take only every third sample, as shown in the illustration
Let we have input sequence: x= [2 3 5 4 6 4];
For x [2n];
6

>>x= [2 3 5 4 6 4];
>>n=2n; 5

>>stem(n,x);
4

0
-4 -3 -2 -1 0 1 2 3 4 5 6
Up Sampling:
When up sampling, we have a case such as x (n) →x (n/3), for
n such that n/3 ∈ Z. This will space out the existing samples to
every third point in time, as shown in the illustration.

For x[1/2n]: 6

>>x= [2 3 5 4 6 4];
>>n=(1/2)n; 5

>>stem(n,x);
4

0
-1 -0.5 0 0.5 1 1.5

Tasks:
Q: Applying following operations on Unit step sequence, Unit ramp sequence & Exponential sequence
using Matlab and also plot the signals:

 x[-n]
 x[-n+4]
 x[-n-4]
 x[n-4]
 x[5n]
 x[n/4]

POSTLAB:

Q1: Today the world is going to be digitized; still analog signals & systems are not discarded. Give your
comments.

Q 2: what is sampling of signals? Analyze the frequency of a signal when it is:

a) Down sampled
b) Up sampled

Also discuss the application of each case.


LAB # 03
Convolution
AIM: To write a MATLAB program to convolve:
Continuous time signals
Discrete time signals
THEORY:
Convolution is usually defined via the convolution integral for continuous time functions or the
convolution sum for discrete-time functions. The convolution of two continuous time functions h(t) and
x(t) written as:
∞ ∞

𝒙(𝒕) ∗ 𝒉(𝒕) = ∫ 𝒉() 𝒙(𝒕 − ) = ∫ 𝒙() 𝒉(𝒕 − )


−∞ −∞

The convolution integral exists if h(t) and x(t) are absolutely integrable.
The convolution of two discrete-time functions h (t) and x (t) can be found using the convolution sum
∞ ∞

𝒉[𝒏] ∗ 𝒙[𝒏] = ∑ 𝒉[ 𝒌] 𝒙[𝒏 − 𝒌] = ∑ 𝒉[ 𝒏 − 𝒌]𝒙[𝒌]


−∞ −∞

(a) Convolution of Continuous Time Signals:

ALGORITHM:
 Define the input signals
 Using ‘conv’ function to convolve the inputs
 Using ‘sub plot’ function to plot the signals
MATLAB CODE:
tint=0; 2

tfinal=10;
tstep=.01; 1

t=tint:tstep:tfinal;
0
x=1*((t>=0)&(t<=1)); 0 0.5 1 1.5 2 2.5 3 3.5 4
subplot(3,1,1), plot(t,x) 2
axis([0 4 0 2])
h=1*((t>=0)&(t<=1)); 1

subplot(3,1,2),plot(t,h)
axis([0 4 0 2]) 0
0 0.5 1 1.5 2 2.5 3 3.5 4
t2=2*tint:tstep:2*tfinal; 2
y=conv(x,h)*tstep;
subplot(3,1,3),plot(t2,y) 1
axis([0 4 0 2])
0
0 0.5 1 1.5 2 2.5 3 3.5 4
(b) Convolution of Discrete Signals

ALGORITHM:-
 Get the starting point of input signals
 Get the coefficients of input signals
 Using ‘conv’ function to convolve the inputs
 Using ‘stem’ function plot the signals
MATLAB CODE :

clc;
clear all;
close all;
a=input('Enter the starting point of x[n]=');
b=input('Enter the starting point of h[n]=');
x=input('Enter the co-efficients of x[n]=');
h=input('Enter the co-efficients of
h[n]=');
INPUT x(n)
y=conv(x,h); 2

Amplitude
subplot(3,1,1)
0
p=a:(a+length(x)-1)
stem(p,x) -2
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
grid on Time
xlabel('Time') IMPULSE RESPONSE h(n)
4
ylabel('Amplitude')

Amplitude
title('INPUT x(n)') 2
subplot(3,1,2)
0
q=b:(b+length(h)-1) 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
stem(q,h) Time
LINEAR CONVOLUTION
grid on 10 Amplitude
xlabel('Time');
5
ylabel('Amplitude');
title('IMPULSE RESPONSE h(n)'); 0
-1 -0.5 0 0.5 1 1.5 2 2.5 3
subplot(3,1,3); Time
n=a+b:length(y)+a+b-1;
stem(n,y);
grid on;
disp(y)
xlabel('Time');
ylabel('Amplitude');
title('LINEAR CONVOLUTION');

SAMPLE :
Enter the starting point of x[n]=-1
Enter the starting point of h[n]=0
Enter the co-efficients of x[n]=[2 -1 1]
Enter the co-efficients of h[n]=[3 2 1]
MATLAB RESPONSE:

p = -1 0 1

q = 0 1 2

y= 6 1 3 1 1

TASKS:
Q1: for following circuit diagram, the time constant of the circuit is RC = 2.5´10-3 sec and the impulse
1
1
response of the system is ℎ (𝑡) = 𝑅𝐶 𝑒 −𝑅𝐶𝑡 . The input to the system is a pulse waveform with amplitude
of 4 Volts, a period of 0.02 seconds, and a duty cycle of 50%. Use the Matlab function conv for
convolution. For each set of signals, plot x (t), h (t) and y (t) as subplots in the same figure.
Q2: perform convolution on following discrete time signals using MATLAB:
(1) x(n) = { 1,2,4 }, h(n) = {1,1,1,1,1}
(2) x (n) = { 1,2,3,4,5 }, h(n) = {1}
(3) x (n) = { 1,2,0,2,1}, h(n) = x(n)
Use the Matlab function conv. For each set of signals, plot x (n), h (n) and y (n) as subplots in the same
figure.

POSTLAB:

Q1: What happened if a signal is convolved with itself?

Q2: Give some applications of convolution.


LAB # 04
Solution of Ordinary Differential Equations in MATLAB
AIM: To find solution of differential equations
To find the roots of characteristic equations

THEORY:
MATLAB has an extensive library of functions for solving ordinary differential equations. In these notes,
we will only consider the most rudimentary.

4.1 First Order Equations


Though MATLAB is primarily a numeric package, it can certainly solve straightforward differential
equations symbolically. Suppose, for example, that we want to solve the first order differential equation

y’(x) = xy: eq (4.1)

We can use MATLAB's built-in function dsolve (). The input and output for solving this problem in
MATLAB is given below.

>>y = dsolve('Dy = y*x','x')


y = C1*exp(1/2*x^2)

Notice in particular that MATLAB uses capital D to indicate the derivative and requires that the entire
equation appear in single quotes. MATLAB takes t to be the independent variable by default, so here x
must be explicitly specified as the independent variable. Alternatively, if you are going to use the same
equation a number of times, you might choose to define it as a variable, say, eqn1.
>>eqn1 = 'Dy = y*x'
eqn1 =
Dy = y*x
>>y = dsolve(eqn1,'x')
y = C1*exp(1/2*x^2)
To solve an initial value problem, say, equation (1.1) with y(1) = 1, use
>>y = dsolve(eqn1,'y(1)=1','x')
y =
1/exp(1/2)*exp(1/2*x^2)
or
>>inits = 'y(1)=1';
>>y = dsolve(eqn1,inits,'x')
y = 1

1/exp(1/2)*exp(1/2*x^2) 0.95

0.9
To plot the function obtained by solution:
0.85

>>x = linspace(0,1,20); 0.8

>>z = eval(vectorize(y)); 0.75


>>plot(x,z)
Suppose we would like to evaluate our solution y(x) 0.7

at the point x = 2. We need only define x as 2 in the 0.65

workspace and then evaluate y:


>>x=2; 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
>>eval(y)
On the other hand, we may want to find the value of x for which y is equal to 7. We want to use solve(),
so our arguments should be strings. MATLAB's command for concatenating strings is strcat(). First, we
convert y into a string with the command char(), and then we attach the string '=7'. We have,
>>solve(strcat(char(y),'=7'))

4.2 Second and Higher Order Equations:


Suppose we want to solve and plot the solution to the second order equation

Y”(x) + 8y’(x) + 2y(x) = cos(x); y(0) = 0; y’(0) = 1: eq (4.2)

The following (more or less self-explanatory) MATLAB code


0.2
suffices:

>>eqn1 = 'D2y + 8*Dy + 2*y = cos(x)' 0.15

>>inits = 'y(0)=0, Dy(0)=1';


>>y = dsolve(eqn1,inits,'x') 0.1
>>z = eval(vectorize(y));
>>plot(x,z)
0.05
To simplify the answer use:

>>a=simple(y) 0

Roots of Polynomials: -0.05


0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

Matlab can treat a vector as a polynomial. It will assume that the numbers represent the coefficients of
the polynomial going from highest-order to lowest order.
>>p = [1 2 2 4 1]
Can represent the polynomial x^4 + 2x^3 + 2x^2 + 4x + 1. There are a number of functions that use this
representation of polynomials:
>>roots (p)
Gives you the roots of the polynomial represented by the vector p.
>>polyval(p,4)
Gives you the value of the polynomial p when x = 4. Similarly,
>>polyval(p,[1:10])
Gives you the value of the polynomial evaluated at each of the points in the vector. (It returns another
vector the same size.)
Tasks:

Q1: Find the solution of following equations and plot the output using Matlab:
𝑑𝑦
1. 𝑑𝑥
= −5𝑦
𝑑𝑦
2. = 2𝑦; 𝑦(0) = 5
𝑑𝑥
3. Y”(x) + 10y’(x) - 2y(x) = ex ; y(0) = 0; y’(0) = 1:
Find y(2), 5 y(.5) & y(-8) after finding the solutions in each case.

POSTLAB:

Q1: Analyze the function of following commands in your words:

a) dsolve()
b) solve()
c) strcat()
d) poly val()
e) roots()
f) vectorize()

Q 2: what is the difference between function of “colon operator” and “linspace()”.


LAB # 05
System Response
AIM: To test simple impulse & unit step responses to systems with arbitrary transfer functions
THEORY:
Transfer Functions: A Transfer Function is the ratio of the output of a system to the input of a system, in
the Laplace domain considering its initial conditions and equilibrium point to be zero. If we have an
input function of X(s), and an output function Y(s), we define the transfer function H(s) to be:

Defining a Transfer Function:


To define a transfer function one gives MATLAB the command tf(num,den). The vector num contains
the coefficients of the numerator polynomial and the vector den contains the coefficient of the
denominator polynomial. The first element of each vector is the coefficient of the highest power in the
polynomial, and each element afterwards corresponds to the next lower power of s.
e.g : G(s) =1/(0.1s + 1)

Giving MATLAB the command


>>G = tf([1],[0.1 1])
Cause MATLAB to respond with

Transfer function:
1
---------
0.1 s + 1

Impulse Response:

The impulse response of a system is the output of the system when a unit impulse function is used as
the input.
To examine G's impulse response, one need only give MATLAB the command impulse (G). To this
command, MATLAB responds by producing Figure 5.2.

Figure 5.2: The impulse response of the system


whose transfer function is G(s) = 1/(0.1s + 1)

Step Response

Similarly to the impulse response, the step response


of a system is the output of the system when a unit
step function is used as the input. The step response is a common analysis tool used to determine
certain metrics about a system.
To examine the step response all one need do is give MATLAB the command step(G). To this command,
MATLAB responds by producing Figure 5.3

Figure 5.3: The step response of the system whose transfer function is G(s) =
1/(0.1s + 1)

Characteristics of step response:

 Rise Time
 Overshoot
 Settling Time
 Delay Time
 Peak Time
 Steady-State Error

System Characteristics on Response Plots:

This example shows how to display system characteristics such as settling time and overshoot on step
response plots. Create a transfer function model and plot its response to a step input at t = 0.

H = tf([8 18 32],[1 6 14 24]);


stepplot(H)
 Display the peak response on the plot as shown below:
 Right-click anywhere in the figure and select Characteristics > Peak Response from the menu.

 A marker appears on the plot indicating the peak response. Horizontal and vertical dotted lines
indicate the time and amplitude of that response.

 Click the marker to view the value of the peak response and the overshoot in a data tip.

 You can use a similar procedure to select other characteristics such as settling time and rise time
from the Characteristics menu and view the values.
Tasks:
1. Analyze the system whose transfer function is
G(s) = s/ (s2 + s + (2π100)2) :
(a) Find the impulse response of the system.
(b) Explain the frequency of the oscillations that you see.
(c) Find the step response of the system.
2. Consider the system of Figure 5.4. Let H(s) = 1, having general T(s)= G(s)/(1+G(s)*H(s)),
Find the step response of the system described by the figure when:
(a) G(s) = 0.125/(s2 + s)
(b) G(s) = 0.25/(s2 + s)
(c) G(s) = 0.5/(s2 + s)
(d) G(s) = 1/(s2 + s)
(e)What effect does the increased gain have on the system's performance?
(Please address both the system's rise time and the amount of overshoot in the system's output.)

POSTLAB:

Q 1: what is impulse response of a system? Give a brief account on the importance of impulse response
of an LTI system.

Q 2: what is step response of a system? Discuss step response parameters briefly

Q 3: what happens to the system’s settling when the gain of the system given in task 2, is increased?
LAB # 06
Laplace Transforms using MATLAB
AIM: To Calculate the Laplace Transform using Matlab

THEORY:

The Laplace transform is an integral transform perhaps second only to the Fourier transform in its utility
in solving physical problems. The Laplace transform is particularly useful in solving linear ordinary
differential equations such as those arising in the analysis of electronic circuits. The Laplace transforms
deals with differential equations, the s-domain, and the s-plane.

The Laplace transform is defined by

Calculating the Laplace F(s) transform of a function f(t) is quite simple in Matlab. First you need to
specify that the variable t and s are symbolic ones. This is done with the command:
>>syms t s
Next you define the function f(t). The actual command to calculate the transform is:
>> F=laplace(f,t,s)
To make the expression more readable one can use the commands:
>>simplify
and
>>pretty.
Here is an example for the function f(t),

f(t)= -1.25+ 3.5t e-2t +1.25 e-2t


>> syms t s
>> f=-1.25+3.5*t*exp(-2*t)+1.25*exp(-2*t);
>> F=laplace(f,t,s)

F =
-5/4/s+7/2/(s+2)^2+5/4/(s+2)
This corresponds to F(s),
𝑠−5
𝐹(𝑠) =
𝑠(𝑠 + 2)2

Alternatively, one can write the function f(t) directly as part of the Laplace command:
>>F2=laplace(-1.25+3.5*t*exp(-2*t)+1.25*exp(-2*t))
TASKS:

Find the Laplace transforms of the given functions manually and verify your results with MATLAB.

(a)
(b)

(c)

(d)

POSTLAB:

Q1: How Laplace transform can be implemented in Matlab using its definition? Write the relevant code.

Q2: Give some applications of Laplace transform.


LAB # 07

Inverse Laplace Transform using Matlab


AIM: To Calculate the Inverse Laplace Transform using Matlab

THEORY:

Inverse Laplace Transform of F(s) uses the following notation.

The command one uses now is ilaplace. One also needs to define the symbols t and s. Lets calculate the
inverse of the function F(s),
𝑠−5
𝐹(𝑠) =
𝑠(𝑠 + 2)2

>> syms t s
>> F=(s-5)/(s*(s+2)^2);
>> ilaplace(F)
ans =
-5/4+(7/2*t+5/4)*exp(-2*t)
>> simplify(ans)
ans =
-5/4+7/2*t*exp(-2*t)+5/4*exp(-2*t)
>> pretty(ans)
- 5/4 + 7/2 t exp(-2 t) + 5/4 exp(-2 t)
Which corresponds to f(t)
f(t)= -1.25+ 3.5t e-2t +1.25 e-2t
Alternatively one can write
>> ilaplace((s-5)/(s*(s+2)^2))
Here is another example.
10(𝑠 + 2)
𝐹(𝑠) =
𝑠(𝑠 2 + 4𝑠 + 5)
>> F=10*(s+2)/(s*(s^2+4*s+5));
>> ilaplace(F)
ans =
-4*exp(-2*t)*cos(t)+2*exp(-2*t)*sin(t)+4
Which gives f(t),
f(t)=[4 - 4 e-2t cos(t)+2 e-2t sin(t)] u(t)

TASKS: Find the inverse transform of each of the following functions manually and verify your results
with MATLAB.

(a)
(b)

(c)

(d)
LAB # 08
SIMULINK
AIM: To simulate and verify the control system using Simulink LTI control tool blocks

 Introduction to Simulink:

Simulink (Simulation and Link) is an extension of MATLAB by Mathworks Inc. It works with MATLAB to
offer modeling, simulation, and analysis of dynamical systems under a graphical user interface (GUI)
environment. The construction of a model is simplified with click-and-drag mouse operations. Simulink
includes a comprehensive block library of toolboxes for both linear and nonlinear analyses.

Getting Started :

To start a Simulink session, you'd need to bring up Matlab program first. From Matlab command
window, enter:
>> simulink

Alternately, you may click on the Simulink icon located on the toolbar as shown:

Simulink's library browser window like one shown below will pop up presenting the block set for model
construction.To see the content of the blockset, click on the "+" sign at the beginning of each toolbox.

To start a model, click on the NEW FILE ICON as shown in the screenshot above. Alternately, you may
use keystrokes CTRL+N.
A new window will appear on the screen. You will be constructing your model in this window. Also in
this window the constructed model is simulated. A screenshot of a typical working (model) window is
shown below:

. A simple model is used here to introduce some basic features of Simulink. Please follow the steps
below to construct a simple model.

STEP 1: CREATING BLOCKS:

From BLOCK SET CATEGORIES section of the SIMULINK LIBRARY BROWSER window, click on the "+" sign
next to the Simulink group to expand the tree and select (click on) Sources.

A set of blocks will appear in the BLOCKSET group. Click on the Sine Wave block
and drag it to the workspace window (also known as model window).

Now you have established a source of your model.

To save a model, you may click on the floppy diskette icon . or from FILE menu, select Save or using
keystrokes CTRL+S. All Simulink model file will have an extension ".mdl".

Continue to build your model by adding more components (or blocks) to your model window. To move
the blocks around, simply click on it and drag it to a desired location.
Once you've dragged over all necessary blocks, the workspace window should consist of the following
components:

STEP 2: MAKING CONNECTIONS:

To establish connections between the blocks, move the cursor to the output port represented by ">"
sign on the block. Once placed at a port, the cursor will turn into a cross "+" enabling you to make
connection between blocks.The connected model is shown:

STEP 3: RUNNING SIMULATION:

You now may run the simulation of the simple system above
by clicking on the play button . Alternately, you may use
keystrokes CTRL+T, or choose Start submenu (under
Simulation menu).

 Handling of Blocks and Lines:

The table below describes the actions and the corresponding keystrokes or mouse operations (Windows
versions).

Actions Keystokes or Mouse Actions

Copying a block from a library Drag the block to the model window
with the left button on the mouse OR
use select the COPY and PASTE from
EDIT menu.
Duplicating blocks in a model Hold down the CTRL key and select
the block with the left mouse drag
the block to a new location.

Display block's parameters Double click on the block

Flip a block CTRL-F

Rotate a block (clockwise 90 deg @ each keystroke) CTRL-R

Changing blocks' names Click on block's label and position the


cursor to desired place.

Disconnecting a block hold down the SHIFT key and drag


the block to a new location

Drawing a diagonal line hold down the SHIFT key while


dragging the mouse with the left
button

Dividing a line move the cursor to the line to where


you want to create the vertex and
use the left button on the mouse to
drag the line while holding down the
SHIFT key

TASKS:

Q: Build the Simulink models of following systems and observe the response:
Exercise 2

Exercise 3
LAB # 09
Discrete Fourier Transform
AIM: - To write a MATLAB program to find the DFT of a sequence
THEORY:
The discrete Fourier transform (DFT) is a fundamental transform in digital signal processing, with
applications in frequency analysis, fast convolution, image processing, etc. Moreover, fast algorithms
exist that make it possible to compute the DFT very efficiently. The algorithms for the efficient
computation of the DFT are collectively called fast Fourier transforms (FFTs).

ALGORITHM:-
 Enter the input sequence x[n]
 Enter the length of sequence N
 Use the Matlab function ‘fft’
 Plot the input and output sequence
MATLAB CODE:
clear all;
close all;
N=input('Enter the value of N');
x=input('Enter the input sequence X(n):');
t=0:N-1;
subplot(2,1,1);
stem(t,x);
xlabel('TIME');
ylabel('AMPLITUDE');
title('INPUT SIGNAL');
grid on;
y=fft(x,N)
subplot(2,1,2);
stem(t,y);
xlabel('TIME');
ylabel('AMPLITUDE');
title('OUTPUT SIGNAL');
grid on;
SAMPLE INPUT:

Enter the value of N 4


Enter the input sequence X(n):[1 2 3 4]
y =
10.0000 -2.0000 + 2.0000i -2.0000 -2.0000 - 2.0000i
TASKS:

1. Find the Discrete Fourier Transform of the following signal manually and verify the result using
Matlab:
f[n] = {1 , 1, -1, -1}, n= 0,1,2,3
POSTLAB:
Q1: Give some application of DFT
Q2: FFT algorithms enhance the efficiency of system on terms of computation. Give your analysis briefly.
LAB #10
Inverse Discrete Fourier Transform
AIM: - TO write a MATLAB program to find the IDFT of a sequence

ALGORITHM:-
 Enter the output sequence y[n]
 Enter the length of sequence,N
 Use the matlab function ‘ifft’
 Plot the input and output sequence

MATLAB CODE:-
clc;
clear all;
close all;
N=input('Enter the value of N=');
y=input('Enter the sequence y[n]=');
t=0:N-1;
subplot(2,1,1);
stem(t,y);
xlabel('TIME');
ylabel('AMPLITUDE');
title('INPUT SIGNAL');
grid on;
x=ifft(y,N)
subplot(2,1,2);
stem(t,x);
xlabel('TIME');
ylabel('AMPLITUDE');
title('OUTPUT SIGNAL');
grid on;

SAMPLE INPUT:-
Enter the value of N=4
Enter the sequence y[n]=[10 -2+2i -2 -2-2i]
x =
1 2 3 4
TASKS:

1. Find the inverse DFT of the following signal manually and verify the result using Matlab:

a. F[k]= {0, 2-2j, 0, 2+2j}, k=0,1,2,3


b. F[k]= {30, 1-j, 1, 1+j}, k=0,1,2,3
2. Modify the code on Matlab to plot the phase response along with magnitude response of the
above mentioned tasks.
LAB # 11
Z-Transform
AIM: Computation of Z Transforms using Matlab Commands
THEORY:
Z Transform, like the Laplace transform, is an indispensable mathematical tool for the design, analysis
and monitoring of systems. The z-transform is the discrete-time counter-part of the Laplace transform
and a generalization of the Fourier transform of a sampled signal. Like Laplace transform the z-transform
allows insight into the transient behavior, the steady state behavior, and the stability of discrete-time
systems. A working knowledge of the z-transform is essential to the study of digital filters and systems.
As analog filters are designed using the Laplace transform, recursive digital filters are developed with a
parallel technique called the z-transformThe Z transform of a discrete time system X[n] is defined as
Power Series.
MATHEMATICALLY;
n= +∞

x (z) = Σx[n]*z -n
n = −∞
ALGORITHM:-
 Specify the symbols
 Enter the input sequence x[n]
 Use the Matlab function ‘ztrans’

Z Transform of A Discrete Time Function:


E.g. X (n) = [1/16n] u (n)

MATLAB CODE:
>>syms z n
>>a=ztrans(1/16^n)
a =
16*z/(16*z-1)

TASKS: Find Z transforms of the following using matlab and compare the observations to the calculated
result:
1. {5.2n−3n} u(n)
2. {7.(3)n−4.(−1)n} u(n)
3. {6n+ 2e−5n} u(n)
4. {13 + sin2n−cos2n} u(n)
5. {e−n} u(n)
6. {cosπn} u(n)
Lab # 12
Inverse Z-Transform
AIM: Computation of Inverse Z Transforms using Matlab Commands

THEORY:
As Z Transform is the infinite Power Series; it exists only for the region for which the series converges
(Region of convergence). Inverse Z Transform is the method of inverting the Z Transform of a signal to
obtain the time domain representation.
The Inverse Z Transform is denoted by:

x(n) = Z-1 [ X(Z)]


ALGORITHM:-
 Specify the symbols
 Enter the input function
 Use the Matlab function ‘iztrans’

E.g. X(Z) = 3*Z / (Z+1)

MATLAB CODE:
syms Z n
iztrans(3*Z/(Z+1))
ans =
3*(-1)^n

Pole Zero Diagram For A Function In Z Domain:


Z plane command computes and display the pole-zero diagram of Z function.
The Command is
Zplane(b,a)
To display the pole value, use root(a)
To display the zero value, use root(b)
X(Z) = [Z-2 + Z-1 ] / [1-2Z-1+3Z-2]

Matlab Code:
b=[0 1 1 ]
a= [1 -2 +3]
roots(a)
roots(b)

zplane(b,a);
ans =
1.0000 + 1.4142i
1.0000 - 1.4142i
ans =
-1 Figure 1
FREQUENCY RESPONSE:
The Freqz function computes and display the frequency response of given Z- Transform
of the function
freqz(b,a,npt,Fs); where
b= Coeff. Of Numerator
a= Coeff. Of Denominator Fs= Sampling Frequency
Npt= no. of free points between and Fs/2

X(Z) = [2+ 5Z-1+9Z-2+5Z-3+3Z-4]/ [5+ 45Z-1+2Z-2+Z-3+Z-4]

MATLAB CODE:
>>b=[2 5 9 5 3]
>>a= [5 45 2 1 1]
>>freqaz(b,a);

TASKS:
Find Inverse Z transforms & plot
a) The pole zero map
b) The Frequency response

Of the following and compare the observations to the


calculated result:
𝑧
1. 𝑋(𝑧) = 2
𝑧 +5𝑧+6
𝑧
2. 𝑋(𝑧) = 2
𝑧 −1.414𝑧+1
𝑧2 +𝑧−1
3. 𝑋(𝑧) = Figure 2
2𝑧2 +3𝑧−1
𝑧(𝑧+0.2)
4. 𝑋(𝑧) = (𝑧−0.2)(𝑧+0.6)
(𝑧+1)3
5. 𝑋(𝑧) = (𝑧+0.5)(𝑧−0.5)2
LAB # 13
Digital Butterworth Filters
AIM: To write a MATLAB program to plot magnitude response and phase response of digital
Butterworth:
Low pass filter
High pass filter
Band pass filter
Band stop filter
THEORY:
The Butterworth filter is a type of signal processing filter designed to have as flat a frequency response
as possible in the passband. It is also referred to as a maximally flat magnitude filter.
ALGORITHM:
 Get the passband and stopband ripples
 Get the passband and stopband edge frequencies
 Calculate the order of the filter using ‘ buttord ’ function
 Find the filter coefficients, using ‘butter’ function
 Draw the magnitude and phase response
(A)Digital Butterworth Low Pass Filter
MATLAB CODE:
clc;
clear all;
close all;
rp=input('enter the passband attenuation:');
rs=input('enter the stop band attenuation:');
wp=input('enter the pass band
frequency:');
ws=input('enter the stop band
frequency:');
[N,wn]=buttord(wp/pi,ws/pi,rp,rs);
[b,a]=butter(N,wn);
freqz(b,a);

SAMPLE INPUT:
enter the passband attenuation:0.4
enter the stop band attenuation:30
enter the pass band frequency:0.2*pi
enter the stop band frequency:0.4*pi

(B) DIGITAL BUTTERWORTH HIGH PASS FILTER

MATLAB CODE:
clc;
clear all;
close all;
rp=input ('Enter the pass band attenuation:');
rs=input ('Enter the stop band attenuation:');
wp=input ('Enter the pass band
frequency:');
ws=input ('Enter the stop band
frequency:');
[N,wn]=buttord(wp/pi,ws/pi,rp,rs);
[b,a]=butter(N,wn,'high');

freqz(b,a);

SAMPLE INPUT:
Enter the pass band attenuation:0.4
Enter the stop band attenuation:30
Enter the pass band frequency:0.6*pi
Enter the stop band frequency:0.2*pi

(C) DIGITAL BUTTERWORTH BAND PASS FILTER


AIM: TO write a MATLAB program to plot magnitude response and phase response of digital Butter
worth Band pass filter
MATLAB CODE

clc;
clear all;
close all;
rp=input('enter the passband attenuation:');
rs=in
put('enter the stop band attenuation:');
wp=input('enter the pass band frequency:');
ws=input('enter the stop band frequency:');
[N,wn]=buttord(wp/pi,ws/pi,rp,rs);
[b,a]=butter(N,wn);
freqz(b,a);

SAMPLE INPUT:-
enter the passband attenuation:0.2
enter the stop band attenuation:20
enter the pass band frequency:[0.2*pi,0.4*pi]
enter the stop band frequency: [0.1*pi,0.5*pi]

(D) DIGITAL BUTTERWORTH BAND STOP FILTER

MATLAB CODE:-
clc;
clear all;
close all;
rp=input('enter the passband attenuation:');
rs=input('enter the stop band
attenuation:');
wp=input('enter the pass band
frequency:');
ws=input('enter the stop band
frequency:');
[N,wn]=buttord(wp/pi,ws/pi,rp,rs);

[b,a]=butter(N,wn,’stop’);
freqz(b,a);

SAMPLE INPUT:-
enter the passband attenuation:0.2
enter the stop band attenuation:20
enter the pass band
frequency:[0.1*pi,0.5*pi]
enter the stop band frequency:[0.2*pi,0.4*pi]

RESULT:- Thus the Amplitude response and phase response of given Butter worth band filters has been
verified.

POSTLAB:

Q: Give your analysis on the magnitude & phase response of each of the filter. Discuss how variations in
parameter are affecting the response.
LAB #14
Digital Chebyshev (Type-1) Filter
(A) Low Pass Filter:
AIM: - TO write a MATLAB program to plot magnitude response and phase response of digital
Chebyshev type-1 Low pass filter
Chebyshev type-1 highpass filter
Chebyshev type-1 band pass filter
Chebyshev type-1 band stop filter

THEORY:
Chebyshev filters are analog or digital filters having a steeper roll-off and more passband ripple (type I)
or stopband ripple (type II) than Butterworth filters. Chebyshev filters have the property that they
minimize the error between the idealized and the actual filter characteristic over the range of the filter,
but with ripples in the passband.
ALGORITHM:-
 Get the passband and stopband ripples
 Get the passband and stopband edge frequencies
 Calculate the order of the filter using ‘ cheb1ord ’ function
 Find the filter coefficients, using ‘cheby1’ function
 Draw the magnitude and phase response

MATLAB CODE:-
clc;
clear all;
close all;
rp=input ('Enter the pass band
attenuation:');
rs=input ('Enter the stop band
attenuation:');
wp=input ('Enter the pass band
frequency:');
ws=input ('Enter the stop band
frequency:');
[N,wn]=cheb1ord(wp/pi,ws/pi,rp,rs);
[b,a]=cheby1(N,rp,wn);
freqz(b,a);

SAMPLE INPUT:-
Enter the pass band attenuation:20
Enter the stop band attenuation:50
Enter the pass band frequency:0.3*pi
Enter the stop band frequency:0.4*pi
RESULTS:- Thus the Amplitude response and phase response of chebyshev type 1 Low pass filter was
verified

(B) Digital Chebyshev (Type-1)High Pass Filter

MATLAB CODE:-
clc;
clear all;
close all;
rp=input ('Enter the pass band
attenuation:');

rs=input ('Enter the stop band


attenuation:');
wp=input ('Enter the pass band
frequency:');
ws=input ('Enter the stop band
frequency:');
[N,wn]=cheb1ord(wp/pi,ws/pi,rp,rs)
;
[b,a]=cheby1(N,rp,wn,'high');
freqz(b,a)
SAMPLE INPUT:-
Enter the pass band attenuation:20
Enter the stop band attenuation:50
Enter the pass band frequency:0.4*pi
Enter the stop band frequency:0.3*pi
RESULT:- Thus the Amplitude response and phase response of chebyshev type 1 high pass filter was
verified

(C) Digital Chebyshev (Type-1) Band Pass Filter

MATLAB CODE:-
clc;
clear all;
close all;
rp=input ('Enter the pass band
attenuation:');
rs=input ('Enter the stop band
attenuation:');
wp=input ('Enter the pass band
frequency:');
ws=input ('Enter the stop band
frequency:');
[N,wn]=cheb1ord(wp/pi,ws/pi,rp,rs);
[b,a]=cheby1(N,rp,wn);
freqz(b,a);
SAMPLE INPUT:-

Enter the pass band attenuation:20


Enter the stop band attenuation:98
Enter the pass band frequency:[0.3*pi,0.5*pi]
Enter the stop band frequency:[0.1*pi,0.8*pi]
RESULT:- Thus the Amplitude response and phase response of chebyshev type 1 band pass filter was
verified

(D) Digital Chebyshev (Type-1) Band Stop Filter


MATLAB CODE:-
clc;
clear all;
close all;
rp=input('Enter the pass band attenuation:');
rs=input('Enter the stop band attenuation:');
wp=input('Enter the pass band frequency:');
ws=input('Enter the stop band frequency:');

[N,wn]=cheb1ord(wp/pi,ws/pi,rp,rs);
[b,a]=cheby1(N,rp,wn,'stop');
freqz(b,a);

SAMPLE INPUT:-
Enter the pass band attenuation:20
Enter the stop band attenuation: 98
Enter the pass band frequency:[0.1*pi,0.8*pi]
Enter the stop band frequency:[0.3*pi,0.5*pi]

RESULT:- Thus the Amplitude response and phase response of chebyshev type 1 band stop pass filter
was verified

POSTLAB:

Q: Give your analysis on the magnitude & phase response of each of the filter. Discuss how variations in
parameter are affecting the response.

Das könnte Ihnen auch gefallen