Transfer Function
Matlab
Transfer function
u (t ) External force: input
y (t ) Displacement of the mass: output
my by ky u (t )
my by ky u (t )
ms Y ( s ) bsY ( s ) kY ( s ) U ( s )
2
Y ( s) 1
G (s) 2
U ( s ) ms bs k
2
Transfer function f (t ) [ A1e s1t An 2e sn2t 2e at C1 cos(t C1 )](u (t )
Y ( s) 0.5 1
G (s) 2 ; U ( s ) ; Step function
U ( s ) s 1.5s 2.5 s
0.5 1 A C1 C1 0.5
Y (s) ; A 0.2
s 1.5s 2.5 s s s (0.7500 + 1.3919j) s ( 0.7500 1.3919j)
2
s 1.5s 2.5 s 0
2
0.5 1 0.5 1
C1 0.1000 + 0.0539j
s (0.7500 1.3919j) s s ( 0.7500 + 1.3919j) 2 1.3919j ( 0.7500 + 1.3919j)
C1 0.1136; C1 2.6474
y(t)= 0.2 + 2e -0.75t ×0.1136cos(1.3919t + 2.6474)
clear; close all; clc
t=0:0.1:7;
y=10*(0.2+2.*exp(-0.75.*t).*0.1136.*cos(1.3919.*t+2.6474));
dy=diff(y)./diff(t);
plot(t,y); hold on
plot(t(2:end),dy);
my by ky u (t )
Transfer function ms 2Y ( s ) bsY ( s ) kY ( s ) U ( s )
clear; close all; clc • m=2; b=3;k=5 Y ( s) 1
G (s) 2
U ( s ) ms bs k
sys = tf(0.5,[1 1.5 2.5]);
1 0.5
step(sys) G (s) 2 2
2 s 3s 5 s 1.5s 2.5
clear; close all; clc
sys = tf(0.5,[1 1.5 2.5]);
hold on
for i=-3:2:6
step(sys*i)
end
(*) step(sys) plots the response of a dynamic
system model to a step input of unit amplitude
Impulse Functions
• In some applications, it is necessary to deal with phenomena of an
impulsive nature.
• For example, an electrical circuit or mechanical system subject to a
sudden voltage or force g(t) of large magnitude that acts over a short
time interval about t0. The differential equation will then have the form
ay by cy g (t ),
where
big, t0 t t0
g (t )
0, otherwise
and 0 is small. 5
my by ky u (t )
Impulse Response Plot • m=2; b=3;k=5
ms 2Y ( s ) bsY ( s ) kY ( s ) U ( s )
Y ( s) 1
clear; close all; clc G (s) 2
U ( s ) ms bs k
sys = tf(0.5,[1 1.5 2.5]); 1 0.5
G (s) 2 2
impulse(sys) 2 s 3s 5 s 1.5s 2.5
clear; close all; clc
sys = tf(0.5,[1 1.5 2.5]);
hold on
for i=-5:2:5
impulse(sys*i)
end
Lsim: Plot simulated time response of dynamic system to arbitrary inputs;
simulated response data Y (s) 1
G (s) 2
U ( s ) ms bs k
Response to Periodic Signal 1 0.5
G (s) 2 2
2 s 3s 5 s 1.5s 2.5
clear; close all; clc
sys = tf(0.5,[1 1.5 2.5]);
tau=10;
[u,t] = gensig("square",tau);
lsim(sys,u,t)
grid on
gensig returns the vector t of time steps and the vector u
containing the corresponding values of the input signal.
Y (s) 1
G (s) 2
U ( s ) ms bs k
Response to Periodic Signal G (s) 2
1
2
0.5
2 s 3s 5 s 1.5s 2.5
clear; close all; clc
sys = tf(0.5,[1 1.5 2.5]);
[u,t] = gensig("sine",1,4);
lsim(sys,u,t)
my by ky u (t )
Matrix Method for Linear DEquations ms 2Y ( s ) bsY ( s ) kY ( s ) U ( s )
Y ( s) 1
State Space model External force: input G (s) 2
u (t ) U ( s ) ms bs k
y (t ) Displacement of the mass: output
my by ky u (t )
x1 (t ) y
x2 (t ) y
x1 (t ) x2
b k 1
x2 (t ) m x2 m x1 m u (t )
0 1 0
x1 (t ) x1 (t )
x (t ) k b 1 u (t )
2 x2 (t )
m m m 9
Matrix Method for Linear DEquations
• m=2; b=3;k=5
0 1 0
x1 (t ) x1 (t )
x (t ) k b 1 u (t )
2 x2 (t )
m m m
0 1 0
x1 (t ) x1 (t )
x (t ) 5 3 1 u (t )
2 x2 (t )
2 2 2
x Ax Bu; x1 (t )
y (t ) 1 0 0u (t )
y Cx + Du x2 (t )
x Ax Bu;
Matrix Method for Linear DEquations
y Cx + Du
clear; close all; clc 0 1 0
x1 (t ) x1 (t )
x (t ) 5 1 u (t )
A = [0, 1; -5/2, -3/2]; B = [0; 1/2]; 3
C = [1, 0]; D = 0; 2 x2 (t )
sys = ss(A,B,C,D); 2 2 2
step(sys); x1 (t )
y (t ) 1 0 0u (t )
x2 (t )
clear; close all; clc
A = [0, 1; -5/2, -3/2]; B = [0; 1/2];
C = [1, 0]; D = 0;
sys = ss(A,B,C,D);
hold on
for i=-5:2:5
step(sys*i)
(*) step(sys) plots the response of a dynamic end
system model to a step input of unit amplitude
x Ax Bu;
Matrix Method for Linear DEquations
Impulse response
y Cx + Du
0 1 0
clear; close all; clc x1 (t ) x1 (t )
A = [0, 1; -5/2, -3/2]; B = [0; 1/2]; x (t ) 5 3 1 u (t )
C = [1, 0]; D = 0; 2 x2 (t )
sys = ss(A,B,C,D); 2 2 2
Figure; hold on
for i=-5:2:5
impulse(sys*i) Response to the Velocity Initial Conditions
end
clear; close all; clc
A = [0, 1; -5/2, -3/2]; B = [0;
1/2];
C = [1, 0]; D = 0;
sys = ss(A,B,C,D);
hold on
initial(sys, [0, 0]);
for i=-5:2:5
initial(sys, [0, i]);
end
x Ax Bu;
Matrix Method for Linear DEquations
y Cx + Du
0 1 0
x1 (t ) x1 (t )
Response to the Displacement Initial Conditions x (t ) 5 3 1 u (t )
2 x2 (t )
2 2 2
clear; close all; clc
A = [0, 1; -5/2, -3/2]; B = [0; 1/2];
C = [1, 0]; D = 0;
sys = ss(A,B,C,D);
hold on
initial(sys, [0, 0]);
for i=-5:2:5
initial(sys, [i, 0]);
end
x Ax Bu;
Matrix Method for Linear DEquations
y Cx + Du
0 1 0
clear; close all; clc x1 (t ) x1 (t )
A = [0, 1; -5/2, -3/2]; B = [0; 1/2];
x (t ) 5 3 1 u (t )
C = [1, 0]; D = 0; 2 x2 (t )
sys = ss(A,B,C,D); 2 2 2
[u,t] = gensig("sine",1,4);
lsim(sys,u,t) Response to Periodic Signal
clear; close all; clc
A = [0, 1; -5/2, -3/2]; B = [0; 1/2];
C = [1, 0]; D = 0;
sys = ss(A,B,C,D);
tau=10;
[u,t] = gensig("square",tau);
lsim(sys,u,t)
grid on
Linear Analysis Using the Linear System Analyzer
To perform linear analysis: clear; close all; clc
• Open the Linear System Analyzer sys_tf = tf(0.5,[1 1.5 2.5]);
A = [0, 1; -5/2, -3/2]; B = [0; 1/2];
showing one or more models
C = [1, 0]; D = 0;
using the following syntax:
sys_ss = ss(A,B,C,D);
linearSystemAnalyzer(sys1, linearSystemAnalyzer(sys_tf,
sys2,...,sysN) sys_ss);
• By default, this syntax opens a
step response plot of your
models, as shown in the
following figure.
Linear Analysis Using the Linear System Analyzer
Linear Analysis Using the Linear System Analyzer
clear; close all; clc
A = [0, 1; -5/2, -3/2]; B = [0; 1/2];
C = [1, 0]; D = 0;
sys_ss = ss(A,B,C,D);
linearSystemAnalyzer(sys_ss);
Linear Analysis Using the Linear System Analyzer
Add more plots to the Linear System Analyzer.
Select Edit > Plot Configurations.
In the Plot Configurations dialog box, select the number of plots
to open.
Linear Analysis Using the Linear System Analyzer
Linear Analysis Using the Linear System Analyzer
To view a different type of response on a plot, right-click and
select a plot type.
clear; close all; clc
A = [0, 1; -5/2, -3/2]; B = [0; 1/2];
C = [1, 0]; D = 0;
sys_ss = ss(A,B,C,D); Response to Periodic Signal
linearSystemAnalyzer(sys_ss);
Linear Analysis Using the Linear System Analyzer
To view a different type of response on a plot, right-click and
select a plot type.
Response to Periodic Signal
clear; close all; clc
A = [0, 1; -5/2, -3/2]; B = [0; 1/2];
C = [1, 0]; D = 0;
sys_ss = ss(A,B,C,D);
linearSystemAnalyzer(sys_ss);
Response to the
Linear Analysis Using the Linear System Analyzer Displacement Initial
Conditions
To view a different type of response on a plot, right-click and
select a plot type.
clear; close all; clc
A = [0, 1; -5/2, -3/2]; B =
[0; 1/2];
C = [1, 0]; D = 0;
sys_ss = ss(A,B,C,D);
linearSystemAnalyzer(sys_ss);
Linear Analysis Using the Linear System Analyzer
Analyze system performance. For example, you can analyze the peak response in the
Bode plot and settling time in the step response plot.
• Right-click to select performance characteristics.
• Click on the dot that appears to view the characteristic value.
System Modeling
Physical setup
The physical parameters for our example are:
(J) Moment of inertia of the rotor 0.01 kg.m^2
(b) Motor viscous friction constant 0.1 N.m.s
(Ke) Electromotive force constant 0.01 V/rad/sec
(Kt) Motor torque constant 0.01 N.m/Amp
(R) Electric resistance 1 Ohm
(L) Electric inductance 0.5 H
System equations
In SI units, the motor torque and back emf constants are equal, that is, K_t = K_e
di
T K t i; e K e ; J b Ki; L Ri K V
dt
1. Transfer Function
Js 2 ( s ) bs( s ) KI ( s ) J b V ( s ) Ks( s )
; ( s ) s ( s )
LsI ( s ) RI ( s ) V ( s ) Ks( s ) K K Ls R
J b
[( Ls R )( s ) K ]s( s ) V ( s )
K K
[( Ls R )( Js b) K 2 ]s( s ) KV ( s )
( s ) K
G (s)
V ( s ) ( Ls R )( Js b) K 2
MATLAB representation
• Transfer Function ( s ) K
G (s)
V ( s ) ( Ls R )( Js b) K 2
J = 0.01;
b = 0.1;
K = 0.01;
R = 1;
L = 0.5;
s = tf('s');
P_motor = K/((J*s+b)*(L*s+R)+K^2)
linearSystemAnalyzer (P_motor);
Linear Analysis Using the Linear
System Analyzer
clear; close all; clc
J = 0.01;
b = 0.1;
K = 0.01;
R = 1;
L1 = 0.5;
L2=0;
s = tf('s');
P_motor1 = K/((J*s+b)*(L1*s+R)+K^2);
P_motor2 = K/((J*s+b)*(L2*s+R)+K^2);
linearSystemAnalyzer (P_motor1,P_motor2);
Linear Analysis Using the Linear
System Analyzer
clear; close all; clc
J = 0.01;
b = 0.1;
K = 0.01;
R = 1;
L = 0.15;
s = tf('s');
P_motor = K/((J*s+b)*(L*s+R)+K^2);
linearSystemAnalyzer (P_motor);
Response to other types of inputs
By right-clicking on the displayed plots and choosing Plot Types > Linear Simulation
• Set the End time (sec) to "5" and • Change the Frequency (Hz) to "0.1" and leave
the Interval (sec) to "0.1". the Amplitude and Duration (secs) as their
default values.
• Click the Design signal button and choose • Click the Insert button at the bottom of the Signal
a Signal type of Sine wave from within the Designer window and the Simulate button at the
window that appears. bottom of the Linear Simulation Tool window.