Modelling Inverted Pendulum Inverted Pendulum Derivation with Lagrange Cart Kinetic Energy Pendulum Kinetic Energy Potential Energy Lagrange's Equation of Motion Respective to 1 Respective to Final Answer State Sapce 2 Linearization M m b I g l q p = = = = = = = = 0.5; 0.2; 0.1; 0.006; 9.8; 0.3; (M+m)*(I+m*l^2)-(m*l)^2; I*(M+m)+M*m*l^2; %denominator for the A and B matrices A = [ 0, 1, 0, 0; 0, 0, 1/(M+m)*m*l, 0; 0, 0, 0, 1; 0, 1/(m*l^2+I)*m*l, 1/(m*l^2+I)*m*g*l*(M+m), 0 ]; B = [ 0; (I+m*l^2)/p; 0; m*l/p]; C = [1 0 0 0; 3 0 0 1 0]; D = [0; 0]; states = {'x' 'x_dot' 'phi' 'phi_dot'}; inputs = {'u'}; outputs = {'x'; 'phi'}; sys_ss = ss(A,B,C,D,'statename',states,'inputname',inputs,'outputname',outputs) sys_ss = A = x 0 0 0 0 x x_dot phi phi_dot x_dot 1 0 0 2.5 phi 0 0.08571 0 17.15 phi_dot 0 0 1 0 B = x x_dot phi phi_dot u 0 1.818 0 4.545 C = x 1 0 x phi x_dot 0 0 phi 0 1 phi_dot 0 0 D = x phi u 0 0 Continuous-time state-space model. sys_tf = tf(sys_ss) sys_tf = From input "u" to output... 1.818 s^2 - 6.782e-14 s - 30.79 x: -----------------------------------------s^4 + 8.882e-16 s^3 - 17.15 s^2 - 0.2143 s phi: 4.545 s + 4.545 -------------------------------------s^3 + 8.882e-16 s^2 - 17.15 s - 0.2143 Continuous-time transfer function. step(sys_ss); 4 5