Bootstrap

【matlab学习】现代控制

(1) SISO Modeling

y ( k + 2 ) + 5 y ( k + 1 ) + 6 y ( k ) = u ( k + 2 ) + 2 u ( k + 1 ) + u ( k ) y(k+2)+5y(k+1)+6y(k)=u(k+2)+2u(k+1)+u(k) y(k+2)+5y(k+1)+6y(k)=u(k+2)+2u(k+1)+u(k)

num_1=[1 2 1];
den_1=[1 5 6];
sys_1=tf(num_1,den_1,-1)

(2) MIMO Modeling

G ( s ) = [ s 2 + 2 s + 1 s 2 + 5 s + 6 s + 5 s + 2 2 s + 3 s 3 + 6 s 2 + 11 s + 6 6 2 s + 7 ] G(s)=\left[\begin{array}{cc}\frac{s^2+2s+1}{s^2+5s+6} & \frac{s+5}{s+2}\\ \frac{2s+3}{s^3+6s^2+11s+6} & \frac{6}{2s+7}\end{array}\right] G(s)=[s2+5s+6s2+2s+1s3+6s2+11s+62s+3s+2s+52s+76]

num={[1 2 1] [1 5]; [2 3] [6]};
den={[1 5 6] [1 2]; [1 6 11 6] [2 7]};
sys_1=tf(num,den) 

(3) 状态空间模型

x ˙ = [ 0 1 − 2 − 3 ] x + [ 0 1 ] u y = [ 1 0 ] x \begin{array}{l}\dot{x}=\left[\begin{array}{cc}0&1\\-2&-3\end{array}\right]x+\left[\begin{array}{c}0\\1\end{array}\right]u \\ y=\left[\begin{array}{c}1&0\end{array}\right]x\end{array} x˙=[0213]x+[01]uy=[10]x

A=[0 1; -2 -3];
B=[0; 1];  C=[1 0];  
D=0;
sys=ss(A,B,C,D)

(4) 状态空间模型->传递函数

x ˙ = [ 0 1 − 2 − 3 ] x + [ 0 1 ] u y = [ 1 0 ] x \begin{array}{l}\dot{x}=\left[\begin{array}{cc}0&1\\-2&-3\end{array}\right]x+\left[\begin{array}{c}0\\1\end{array}\right]u \\ y=\left[\begin{array}{c}1&0\end{array}\right]x\end{array} x˙=[0213]x+[01]uy=[10]x

sys_tf=tf(sys)

(5) 传递函数->状态空间模型

  • 转换函数ss()
sys_1_ss=ss(sys_1)
  • 规范形转换函数canon()
sys_can_ss=canon(sys_1,'modal')
  • 常微分方程(传递函数)转换为状态空间模型函数dif2ss()
    y ′ ′ ′ + 5 y ′ ′ + 8 y ′ + 4 y = 2 u ′ ′ + 14 u ′ + 24 u y^{'''}+5y^{''}+8y^{'}+4y=2u^{''}+14u^{'}+24u y′′′+5y′′+8y+4y=2u′′+14u+24u
num_1=[2 14 24];  den_1=[1 5 8 4];
sys_1=tf(num_1,den_1);% 建立传递函数模型
sys_comp=dif2ss(sys_1,'companion')% 求传递函数的友矩阵形状态空间模型
sys_jord=dif2ss(num_1,den_1,'jordan')% 求传递函数的约旦规范形状态空间模型

(6) 状态空间模型变换

{ x ˙ = [ 0 1 0 0 0 1 − 6 − 11 − 6 ] x + [ 0 0 6 ] u y = [ 1 0 0 ] x \left\{\begin{array}{l}\dot{x}=\left[\begin{array}{ccc}0 & 1 & 0\\0 & 0 & 1\\ -6 & -11 & -6\end{array}\right]x+\left[\begin{array}{c}0 \\ 0 \\ 6\end{array}\right]u \\ y=\left[\begin{array}{ccc}1& 0&0\end{array}\right]x\end{array}\right. x˙= 0061011016 x+ 006 uy=[100]x

P = [ 1 1 1 − 1 − 2 − 3 1 4 9 ] P=\left[\begin{array}{ccc}1&1&1\\-1&-2&-3\\1&4&9\end{array}\right] P= 111124139

A=[0 1 0; 0 0 1; -6 -11 -6];
B=[0; 0; 6];  C=[1 0 0];  D=0;
P=[1 1 1; -1 -2 -3; 1 4 9];
sys_in=ss(A,B,C,D);
sys_out=ss2ss(sys_in,inv(P)) 

(7) 特征值和特征向量

d = eig(A)%只计算所有特征值
[V,D] = eig(A)%同时得到所有特征向量和特征值

(8) 广义特征向量

J = jordan(A)%只计算A矩阵对应的约旦矩阵J
[V,J] = jordan(A)%所有广义特征向量和约旦矩阵J

(9) 状态空间模型->约旦型

x ˙ = [ 0 1 0 0 0 1 − 4 − 8 − 5 ] x + [ 0 0 1 ] u \dot{x}=\left[\begin{array}{ccc}0 & 1&0\\0&0&1\\-4&-8&-5\end{array}\right]x+\left[\begin{array}{c}0\\0\\1\end{array}\right]u x˙= 004108015 x+ 001 u
y = [ 1 0 0 ] x y=\left[\begin{array}{ccc}1&0&0\end{array}\right]x y=[100]x

A=[0 1 0; 0 0 1; -4 -8 -5];
B=[0; 0; 1];  C=[1 0 0];  D=0;
sys_in=ss(A,B,C,D);
[P,J]=jordan(A);
sys_out=ss2ss(sys_in,inv(P))
;