You are on page 1of 7

1.

Objective:
 Learn to compute Laplace transform and inverse Laplace transform in MATLAB.
 Represent transfer function in MATLAB.
 Do some primary analysis of transfer function.
2. Equipment:
 MATLAB
3. Introduction:

Laplace Transform in MATLAB. To compute Laplace transform, an equation must be defined in terms of
variables. The variables in equation are defined using ‘𝒔𝒚𝒎𝒔′ command.

To find inverse Laplace of a function 𝐹(𝑠), partial fraction expansion is required. MATLAB command ‘𝒓𝒆𝒔𝒊𝒅𝒖𝒆’ is used
for this purpose. Once the partial fraction is computed, inverse Laplace is calculated using ‘𝒊𝒍𝒂𝒑𝒍𝒂𝒄𝒆()’ command.
Transfer function of an LTI system is defined as the ratio of the Laplace transform 𝑌(𝑠) of the output signal 𝑦(𝑡) to the
Laplace transform 𝑅(𝑠) of the input signal 𝑟(𝑡) applied to the system.
4. Task #1:

Code:
clc
clear all
close all
syms s t h v
h=((1.5)+(1.25*(exp(-2*t)))
+(2*(cos(2*t))));
v=laplace(h,s)
pretty(v)
simplify(v)

5. Task #2:

Code:
%CS LAB 2 TASK 2
clc
clear all
close all
syms s t
b=[2];
d=[ 1 3 2];
[r p]=residue(b,d)
z=((r(1))/(s-p(1)))+((r(2))/(s-p(2)));
f=ilaplace(z,t)
Task #3:

Code:
%CS LAB 2 TASK 3
clc
close all
clear all
t=0:0.1:10;
syms s
b=[32];
c=[2 12 -32 0];
[r,p]=residue(b,c);
q=[(r(1))./(s-p(1))+(r(2))./(s-
p(2))+(r(3))./(s-p(3))]
a=ilaplace(q,t)
pretty(a)
simplify(a)
plot(t,a,'b')
xlabel('time')
ylabel('q(t)')
title('Inverse Laplace of Q(Y)')
6. Task #4:

Part a:
transfer function:
Part b:
%% Part # 01
num=[3 1];
denum=[1 7 5 1 0];
g=tf(num,denum);
pzmap(g);

Part c& d:
%% Part # 02
t=0:1:10;
step_response=step(g,t);
impulse_response=impulse(g,t);
figure;
plot(t, impulse_response, 'b', t,
step_response, 'r--');
title('Impulse and Step Response');
xlabel('Time');
ylabel('Amplitude');
legend('Impulse Response', 'Step
Response');
grid

Task #5:
Part a:
%% Part # 01
% Define the transfer function
num=[1];
denum=[1 90 900];
sys =tf(num,denum);
figure;
step(sys);
title('Step Response');
xlabel('Time');
ylabel('Amplitude');
figure;
pzmap(sys);
title('Poles of the System');
Poles: Step response:

Part b:
%% Part # 02
% Compute and plot impulse and step
response together
t = 0:0.1:10;
impulse_response = impulse(sys, t);
step_response = step(sys, t);

figure;
plot(t, impulse_response, 'b', t,
step_response, 'r--');
title('Comparison of Impulse and Step
Response');
xlabel('Time');
ylabel('Amplitude');
legend('Impulse Response', 'Step
Response');

Part c:(Stability)
Our system is stable because poles lies on the left sides.
Conclusion:
In this lab, we used MATLAB to learn about Laplace transforms and transfer functions. We discovered
how to convert functions between the time and frequency domains and represent system behavior. Through
basic analysis, like checking stability, we gained insights into how systems respond to inputs. MATLAB's
tools provided a straightforward way to explore these fundamental concepts in engineering.

You might also like