0% found this document useful (0 votes)
17 views

Week 3 Matlab

This document contains a table of contents that lists topics related to Laplace transforms, including the Laplace transform, inverse Laplace transform, partial-fraction decomposition, transfer functions, modeling of mass-spring-damper, cruise control, and DC motor systems. It also provides MATLAB code examples for related calculations and simulations.

Uploaded by

FERHAT BODUR
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)
17 views

Week 3 Matlab

This document contains a table of contents that lists topics related to Laplace transforms, including the Laplace transform, inverse Laplace transform, partial-fraction decomposition, transfer functions, modeling of mass-spring-damper, cruise control, and DC motor systems. It also provides MATLAB code examples for related calculations and simulations.

Uploaded by

FERHAT BODUR
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

Table of Contents

Laplace transform ............................................................................................................................... 1


inverse Laplace transform ..................................................................................................................... 1
partial-fraction .................................................................................................................................... 1
Transfer Function ................................................................................................................................ 2
mass-spring-damper model ................................................................................................................... 4
cruise control model ............................................................................................................................ 4
DC MOTOR ...................................................................................................................................... 5

Laplace transform
Laplace example

syms t
L=laplace(2*exp(-t)+sin(2*t))
pretty(L)

L =

2/(s + 1) + 2/(s^2 + 4)

2 2
----- + ------
s + 1 2
s + 4

inverse Laplace transform


syms s
f=ilaplace(3/(s*(s^2+2 *s+5)));
pretty(f)

/ sin(2 t) \
exp(-t) | cos(2 t) + -------- | 3
3 \ 2 /
- - ---------------------------------
5 5

partial-fraction
num=[3];
denum=[1 2 5 0];
[r,p,k]=residue(num,denum)

r =

1
-0.3000 + 0.1500i
-0.3000 - 0.1500i
0.6000 + 0.0000i

p =

-1.0000 + 2.0000i
-1.0000 - 2.0000i
0.0000 + 0.0000i

k =

[]

Transfer Function
num= [1 0];% Numerator: s
den =[1 2 10];% Denominator: s^2 +2s+10
H=tf(num,den)

s = tf ('s'); % Create Laplace variable


H = s/(s^2 + 2*s + 10)

%%ZPK
z =0;% Zeros
p=[2 1+ i 1-i]% Poles
k=-2% Gain
H=zpk (z,p,k)

num=[1 3];
denum=[1 11 38 40];
roots(denum)

[z,p,k] = tf2zp(num,denum);

[a,b]=zp2tf(z,p,k);

%%state space ss
A = [0 1;-5 -2];
B = [0;3];
C = [0 1];
D = 0;
sys = ss(A,B,C,D)

H =

s
--------------

2
s^2 + 2 s + 10

Continuous-time transfer function.

H =

s
--------------
s^2 + 2 s + 10

Continuous-time transfer function.

p =

2.0000 + 0.0000i 1.0000 + 1.0000i 1.0000 - 1.0000i

k =

-2

H =

-2 s
--------------------
(s-2) (s^2 - 2s + 2)

Continuous-time zero/pole/gain model.

ans =

-5.0000
-4.0000
-2.0000

sys =

A =
x1 x2
x1 0 1
x2 -5 -2

B =
u1
x1 0
x2 3

C =
x1 x2

3
y1 0 1

D =
u1
y1 0

Continuous-time state-space model.

mass-spring-damper model
num=[0.1 0.35 0];
den=[1 3 2];
sys=tf(num,den);
figure (1)
step(sys)
impulse(sys)
grid on
xlabel('time ')
ylabel('x(t)')

cruise control model


num=1/1e3;
denum=[1 50/1e3];

4
figure (2)
step(500*num,denum)

DC MOTOR
R=1;
L=0.5;
Kt=0.01;
Ke=0.01;
K=Ke;
J=0.02;
b=0.1;

s=tf('s');
motor=K/((J*s+b)*(L*s+R)+K^2)
figure (3)
step(motor)

motor =

0.01
--------------------------
0.01 s^2 + 0.07 s + 0.1001

Continuous-time transfer function.

5
state space

A = [-b/J K/J
-K/L -R/L];
B = [0
1/L];
C = [1 0];
D = 0;
motor_ss = ss(A,B,C,D)

motor_ss = ss(motor)

motor_ss =

A =
x1 x2
x1 -5 0.5
x2 -0.02 -2

B =
u1
x1 0
x2 2

6
C =
x1 x2
y1 1 0

D =
u1
y1 0

Continuous-time state-space model.

motor_ss =

A =
x1 x2
x1 -7 -2.502
x2 4 0

B =
u1
x1 0.5
x2 0

C =
x1 x2
y1 0 0.5

D =
u1
y1 0

Continuous-time state-space model.

Published with MATLAB® R2022b

You might also like