Simulation of Inverted Pendulum With Step Response
Simulation of Inverted Pendulum With Step Response
M = 0.5
M = 0.5000
m = 0.2
m = 0.2000
b = 0.1
b = 0.1000
i = 0.006
i = 0.0060
g = 9.8
g = 9.8000
l = 0.3
l = 0.3000
q = (M+m)*(i+m*l^2)-(m*l)^2
q = 0.0132
s = tf('s')
s =
s
Continuous-time transfer function.
P_disp =
-------------------------------------------------------------------------
P_pend =
1.045e-05 s
-----------------------------------------------------
sys_tf =
1: -------------------------------------------------------------------------
1.045e-05 s
2: -----------------------------------------------------
inputs = {'u'}
{'u'}
outputs = {'x';'phi'}
{'x' }
{'phi'}
set(sys_tf,'Inputname',inputs)
set(sys_tf,'Outputname',outputs)
sys_tf
sys_tf =
x: -------------------------------------------------------------------------
1.045e-05 s
phi: -----------------------------------------------------
p = i*(M+m)+M*m*l^2
p = 0.0132
A = [0 1 0 0;
0 -(i+m*l^2)*b/p (m^2*g*l^2)/p 0;
0 0 0 1;
0 -(m*l*b)/p m*g*l*(M+m)/p 0]
A = 4×4
0 1.0000 0 0
0 -0.1818 2.6727 0
0 0 0 1.0000
0 -0.4545 31.1818 0
B = [ 0;
(i+m*l^2)/p;
0;
(m*l)/p]
B = 4×1
1.8182
4.5455
C = [1 0 0 0;
0 0 1 0]
C = 2×4
1 0 0 0
0 0 1 0
D = [0;0]
D = 2×1
inputs = {'u'}
inputs = 1×1 cell array
{'u'}
outputs = {'x';'phi'}
{'x' }
{'phi'}
sys_ss =
A =
x 0 1 0 0
phi 0 0 0 1
B =
x 0
x_dot 1.818
phi 0
phi_dot 4.545
C =
x 1 0 0 0
phi 0 0 1 0
D =
x 0
phi 0
sys_tf = tf(sys_ss)
sys_tf =
x: --------------------------------------
4.545 s - 1.277e-16
phi: ----------------------------------
-5.6064 + 0.0000i
5.5673 + 0.0000i
-0.6980 + 0.6690i
-0.6980 - 0.6690i
0.6266 + 0.6687i
0.6266 - 0.6687i
zero = 4×1
0
5.5651
-5.6041
-0.1428
pole = 0
zero = 3×1
5.5651
-5.6041
-0.1428
t = 0:0.01:1
t = 1×101
impulse(sys_tf,t)
title ('Open Loop Impulse Response')
t = 1×201
u = ones(size(t))
u = 1×201
1 1 1 1 1 1 1 1 1 1 1 1 ⋯
[y,t] = lsim(sys_tf,u,t);
plot(t,y)
title('Open Loop Step Response')
axis([0 3 0 50])
legend('x' , 'phi')
THE END