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)
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)
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˙=[0−21−3]x+[01]uy=[10]x
A=[0 1; -2 -3];
B=[0; 1]; C=[1 0];
D=0;
sys=ss(A,B,C,D)
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˙=[0−21−3]x+[01]uy=[10]x
sys_tf=tf(sys)
sys_1_ss=ss(sys_1)
sys_can_ss=canon(sys_1,'modal')
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')% 求传递函数的约旦规范形状态空间模型
{ 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˙= 00−610−1101−6 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= 1−111−241−39
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))
d = eig(A)%只计算所有特征值
[V,D] = eig(A)%同时得到所有特征向量和特征值
J = jordan(A)%只计算A矩阵对应的约旦矩阵J
[V,J] = jordan(A)%所有广义特征向量和约旦矩阵J
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˙= 00−410−801−5 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))