Transfer Function - Matlab
Transfer Function - Matlab
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
ay by cy g (t ),
where
big, t0 t t0
g (t )
0, otherwise
and 0 is small. 5
my by ky u (t )
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
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
• 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.