📄 ch11_d.m
字号:
% Design the feedback gain matrix for the cart with inverted% pendulum example. This example follows the procedure% outlined in Example 2-3 of "Designing Linear Control% Systems with MATLAB", by K. Ogata%% Note that for this model, the state vector is% [x ; x_dot ; theta_dot ; theta]', so the arrangement of the system% matrices will be different than in the Ogata example.%% System parametersl = 0.5 ; % Pendulum lengthg = 9.8 ; % Gravitym = 0.1 ; % Pendulum bob massM = 2 ; % Cart mass% Get the system matrices[A,B,C,D] = linmod('sysmdl_h',[0,0,0,0],[0])A1 = [A zeros(4,1) ; -C 0] ;B1 = [B ; 0] ; % Define the controllability matrix MMM = [B1 A1*B1 A1^2*B1 A1^3*B1 A1^4*B1] ;% Check the rank of MM, must be 5 if system in completely controllablerank(MM)% Obtain the characteristic polynomialJ = [-1+sqrt(3)*i,0,0,0,0;0,-1-sqrt(3)*i,0,0,0;... 0,0,-5,0,0;0,0,0,-5,0;0,0,0,0,-5] ;Phi = polyvalm(poly(J),A1) ;% Get the feedback matrix using Ackermann's formulaKK = [0,0,0,0,1]*(inv(MM))*Phi k1 = KK(1) ; % x gaink2 = KK(2) ; % x_dot gain k3 = KK(3) ; % theta_dot gaink4 = KK(4) ; % theta gainKI = -KK(5) ; % error integrator gain
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -