0% found this document useful (0 votes)
90 views7 pages

SNS Lab11 SP2020

This document is a laboratory manual on finding the Laplace transform of single-sided and two-sided signals using MATLAB. It introduces the Laplace transform and how to compute it using the laplace command. It also discusses the inverse Laplace transform and computing it using the ilaplace command. The document provides examples of computing the Laplace transform of common functions and the inverse Laplace transform of given signals. It also describes using MATLAB to analyze systems using functions like freqs, pole-zero plots, and symbolic math commands.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
90 views7 pages

SNS Lab11 SP2020

This document is a laboratory manual on finding the Laplace transform of single-sided and two-sided signals using MATLAB. It introduces the Laplace transform and how to compute it using the laplace command. It also discusses the inverse Laplace transform and computing it using the ilaplace command. The document provides examples of computing the Laplace transform of common functions and the inverse Laplace transform of given signals. It also describes using MATLAB to analyze systems using functions like freqs, pole-zero plots, and symbolic math commands.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Signals and Systems

(EL-223)

LABORATORY MANUAL

Dr. Shahzad Saleem

Engr. Fakhar Abbas

(LAB # 11)
FINDING LAPLACE TRANSFORM OF SINGLE-SIDED AND TWO-SIDED
SIGNALS USING MATLAB

Prepared by: Engr. Fakhar Abbas Version: 2.00

Verified by: Dr. Waqas bin Abbas, Dr. Shahzad Updated: Spring 2020
Saleem
Finding Single Sided And Two Sided Signals Laplace Transform Using MATLAB Lab 11

Lab # 11: FINDING SINGLE SIDED AND TWO SIDED SIGNALS


LAPLACE TRANSFORM USING MATLAB
Objective: In this lab, you will learn:
 How to find laplace transform of single sided and two sided signals
 laplace command
 Finding Inverse Laplace Transform
 ilaplace command
 residue command
 To compute frequency response using freqs()
 To analyze RC Circuit response using Laplace Transform

Tool Used: MATLAB

Description:

MATLAB provides command for working with transforms, such as the Laplace and Fourier transforms.
Transforms are used in science and engineering as a tool for simplifying analysis and look at data from
another angle.
For example, laplace transform allows us to convert a differential equation to an algebraic equation.
MATLAB provides the laplace command to work with Laplace transform.

The Laplace Transform


The Laplace transform of a function of time 𝑓(𝑡) is given by the following integral:

𝐹(𝑠) = ∫ 𝑓(𝑡)𝑒 −𝑠𝑡 𝑑𝑡,


−∞
whereas, the inverse Laplace transform is computed using following integral
1 𝜎+𝑗∞
𝑓(𝑡) = ∫ 𝐹(𝑠)𝑒 𝑠𝑡 𝑑𝑠.
2𝜋𝑗 𝜎−𝑗∞

MATLAB allows us to compute the Laplace transform using the command laplace.
Example:
Code Command Window Output
syms t ans = 1/s^2
laplace(t)

Similarly, we can compute the inverse Laplace transform using the command ilaplace.
Example:
Code Command Window Output
syms s ans = t
ilaplace(1/s^2)

SIGNALS AND SYSTEMS LAB NUCES, ISLAMABAD Page 2 of 7


Finding Single Sided And Two Sided Signals Laplace Transform Using MATLAB Lab 11

PRACTICE TASK:
Compute the Laplace transform of following commonly used functions.

Continuous-time Functions Code Output

𝑥(𝑡) = 𝑡 2
𝑥(𝑡) = 𝑒 −𝑏𝑡
𝑥(𝑡) = cos(𝜔0 𝑡))

PRACTICE TASK:
Compute the inverse Laplace transform of given signals:

Laplace-domain Functions Code Output


1
𝑋(𝑠) =
𝑠2
1
𝑋(𝑠) =
𝑠3
2
𝑋(𝑠) =
𝑠+𝜔
𝑠
𝑋(𝑠) = 2
𝑠 +4
𝑠
𝑋(𝑠) = 2
𝑠 +𝜔

Finding Frequency Response of a System using freqs command:

Num = [0.2 0.3 1]; % Numerator Coefficients


Den = [1 0.4 1]; % Denominator Coefficients
freqs(Num,Den) % computing Frequency Response of given system
%% 2nd Method you can also plot frequency response as given below:
[H,w] = freqs(Num,Den);
mag = abs(H);
phase = angle(H)*180/pi;
subplot(211),loglog(w,mag),set(gca,'xgrid','on','ygrid','on')
set(gca,'xlim',[w(1) w(length(w))])
xlabel('Frequency (rad/s)')
ylabel('Magnitude')
subplot(212), semilogx(w,phase),set(gca,'xgrid','on','ygrid','on')
set(gca,'xlim',[w(1) w(length(w))])
xlabel('Frequency (rad/s)')
ylabel('Phase (degrees)')

SIGNALS AND SYSTEMS LAB NUCES, ISLAMABAD Page 3 of 7


Finding Single Sided And Two Sided Signals Laplace Transform Using MATLAB Lab 11

SIGNALS AND SYSTEMS LAB NUCES, ISLAMABAD Page 4 of 7


Finding Single Sided And Two Sided Signals Laplace Transform Using MATLAB Lab 11

SIGNALS AND SYSTEMS LAB NUCES, ISLAMABAD Page 5 of 7


Finding Single Sided And Two Sided Signals Laplace Transform Using MATLAB Lab 11

By applying inverse Laplace transform, we will get


𝑦(𝑡) = 𝑟(1)𝑒 𝑝(1)𝑡 + 𝑟(2)𝑒 𝑝(2)𝑡 + ⋯ + 𝑟(𝑛)𝑒 𝑝(𝑛)𝑡
Examples related to Transfer Functions

% Generating a Transfer Function


clc; clear all; close all;
num = [2 1]; % Numerator Co-efficients
den = [10 3 2]; % Denominator Co-efficients
H = tf(num, den)% Making H(s)
% [num,den] = eqtflength(num,den); % For matching length of num
and den
[z,p,k] = tf2zp(num,den)% finding zero, poles and gain
H1 = zpk(z,p,k)% getting back transfer function from z, p and k
% 2nd Method for Generating Transfer Function (T/F)
s = tf('s'); % making an object for transfer function
H2 = (2*s + 1)/((10*(s)^2) + (3*s) + 2) % Defining H(s)
[H_num,H_den]= tfdata(H2,'v')% getting Num and Den coefficients
from Continuous T/F
% v shows that we want Answer in Numeric Vector
[z,p,k] = zpkdata(H2,'v') % Finding z, p, k from Continuous T/F
directly
H3 = zpk(z,p,k)% getting back tranfer function from z, p and k

Code related to Pole Zero Plot


clc;close all
% Let H = s-6/s^2-5*s+6;
b = [1 -6]; % Numerator coefficients
a = [1 5 6];% Denominator coefficients
[b,a] = eqtflength(b,a); % making a and b length equal
pzmap(b,a)% Plotting Pole Zero plot using info in b and a
[z,p,k] = tf2zp(b,a) )% Finding zeros and poles from T/F
fvtool(b,a,'polezero') % Frequency Visualization Tool: used to
plot frequency response, impulse and unit step response, pole-zero
plot and many more info related to given system
text(real(z)+.1,imag(z),'Zero')
text(real(p)+.1,imag(p),'Pole')
% Confirmation of zeros and poles with roots command
Z = roots(b) % Finding roots or zeros of numerator
P = roots(a) % Finding roots or poles of denominator
K = b(1)/a(1)
[r,p,k] = residue(b,a) % For Partial Fraction
[b,a] = residue(r,p,k) % Getting num and den coefficient from
r,p,k
H = tf(b,a) % Retrieving transfer function back from r,p,k

SIGNALS AND SYSTEMS LAB NUCES, ISLAMABAD Page 6 of 7


Finding Single Sided And Two Sided Signals Laplace Transform Using MATLAB Lab 11

Very Useful symbolic commands for basic manipulations: Try this in Matlab
clc;clear;close all
% Expand a polynomial, make it look nice, solve it, and check the
solution.
syms x a % tell Matlab that x and a are symbols
f = (x-1)*(x+a)*(x+pi)*(x+2)*(x+3); % define function f
pretty(f) % print f in more readable form
g = expand(f) % re-write f, multiply everything out
fact = factor(g) % factorize given polynomial in nice way
h = collect(g) % re-write again by collecting terms
soln = solve(h,x) % find all solutions by letting h = 0
check = subs(f,x,soln(5)) % check say the 5th solution satisfy the
function or not

SIGNALS AND SYSTEMS LAB NUCES, ISLAMABAD Page 7 of 7

You might also like