# ss2tf

## 语法

``[b,a] = ss2tf(A,B,C,D)``
``[b,a] = ss2tf(A,B,C,D,ni)``

## 说明

``[b,a] = ss2tf(A,B,C,D)` 将方程组的状态空间表示形式转换为等同的传递函数。`ss2tf` 返回连续时间方程组的拉普拉斯变换传递函数和离散时间方程组的 Z 变换传递函数。`

``[b,a] = ss2tf(A,B,C,D,ni)` 返回当具有多个输入的方程组的第 `ni` 个输入受单位冲激影响时所生成的传递函数。`

## 示例

```Fs = 5; dt = 1/Fs; N = 50; t = dt*(0:N-1);```

`$\begin{array}{c}x\left(k+1\right)=Ax\left(k\right)+Bu\left(k\right),\\ y\left(k\right)=Cx\left(k\right)+Du\left(k\right),\end{array}$`

`$A=\left(\begin{array}{cc}\mathrm{cos}\Delta t& \mathrm{sin}\Delta t\\ -\mathrm{sin}\Delta t& \mathrm{cos}\Delta t\end{array}\right),\phantom{\rule{1em}{0ex}}B=\left(\begin{array}{c}1-\mathrm{cos}\Delta t\\ \mathrm{sin}\Delta t\end{array}\right),\phantom{\rule{1em}{0ex}}C=\left(\begin{array}{cc}-1& 0\end{array}\right),\phantom{\rule{1em}{0ex}}D=\left(\begin{array}{c}1\end{array}\right).$`

```A = [cos(dt) sin(dt);-sin(dt) cos(dt)]; B = [1-cos(dt);sin(dt)]; C = [-1 0]; D = 1;```

```u = [1 zeros(1,N-1)]; x = [0;0]; for k = 1:N y(k) = C*x + D*u(k); x = A*x + B*u(k); end```

```stem(t,y,'filled') xlabel('t')```

```[b,a] = ss2tf(A,B,C,D); yt = filter(b,a,u); stem(t,yt,'filled') xlabel('t')```

`$H\left(z\right)=\frac{1-{z}^{-1}\left(1+\mathrm{cos}\Delta t\right)+{z}^{-2}\mathrm{cos}\Delta t}{1-2{z}^{-1}\mathrm{cos}\Delta t+{z}^{-2}}.$`

```bf = [1 -(1+cos(dt)) cos(dt)]; af = [1 -2*cos(dt) 1]; yf = filter(bf,af,u); stem(t,yf,'filled') xlabel('t')```

```Fs = 16; dt = 1/Fs; N = 257; t = dt*(0:N-1);```

`$\begin{array}{c}x\left(n+1\right)=Ax\left(n\right)+Bu\left(n\right),\\ y\left(n\right)=Cx\left(n\right)+Du\left(n\right),\end{array}$`

`$A=\mathrm{exp}\left({A}_{c}\Delta t\right),\phantom{\rule{1em}{0ex}}B={A}_{c}^{-1}\left(A-I\right){B}_{c},\phantom{\rule{1em}{0ex}}C=\left(\begin{array}{cccc}-2& 0& 1& 0\\ 1& 0& -2& 0\end{array}\right),\phantom{\rule{1em}{0ex}}D=I,$`

`${A}_{c}=\left(\begin{array}{cccc}0& 1& 0& 0\\ -2& 0& 1& 0\\ 0& 0& 0& 1\\ 1& 0& -2& 0\end{array}\right),\phantom{\rule{1em}{0ex}}{B}_{c}=\left(\begin{array}{cc}0& 0\\ 1& 0\\ 0& 0\\ 0& 1\end{array}\right),$`

$I$ 表示合适大小的单位矩阵。

```Ac = [0 1 0 0; -2 0 1 0; 0 0 0 1; 1 0 -2 0]; A = expm(Ac*dt); Bc = [0 0; 1 0; 0 0; 0 1]; B = Ac\(A-eye(4))*Bc; C = [-2 0 1 0; 1 0 -2 0]; D = eye(2);```

```ux = [1 zeros(1,N-1)]; u0 = zeros(1,N); u = [ux;u0];```

```x = [0 0 0 0]'; y = zeros(2,N); for k = 1:N y(:,k) = C*x + D*u(:,k); x = A*x + B*u(:,k); end```

```stem(t,y','.') xlabel('t') legend('a_1','a_2') title('Mass 1 Excited') grid```

```[b1,a1] = ss2tf(A,B,C,D,1); y1u1 = filter(b1(1,:),a1,ux); y1u2 = filter(b1(2,:),a1,ux);```

```stem(t,[y1u1;y1u2]','.') xlabel('t') legend('a_1','a_2') title('Mass 1 Excited') grid```

```u = [u0;ux]; x = [0;0;0;0]; for k = 1:N y(:,k) = C*x + D*u(:,k); x = A*x + B*u(:,k); end```

```stem(t,y','.') xlabel('t') legend('a_1','a_2') title('Mass 2 Excited') grid```

```[b2,a2] = ss2tf(A,B,C,D,2); y2u1 = filter(b2(1,:),a2,ux); y2u2 = filter(b2(2,:),a2,ux);```

```stem(t,[y2u1;y2u2]','.') xlabel('t') legend('a_1','a_2') title('Mass 2 Excited') grid```

## 详细信息

### 传递函数

• 对于离散时间系统，状态空间矩阵通过

`$\begin{array}{c}x\left(k+1\right)=\text{A}\text{\hspace{0.17em}}x\left(k\right)+\text{B}\text{\hspace{0.17em}}u\left(k\right)\\ y\left(k\right)=\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{C}\text{\hspace{0.17em}}x\left(k\right)+\text{D}\text{\hspace{0.17em}}u\left(k\right).\end{array}$`

与状态向量 x、输入 u 和输出 y 相关。

传递函数是方程组的冲激响应的 Z 变换。可以按状态空间矩阵表示形式将其表示为

`$\text{H}\left(z\right)\text{=C}{\left(z\text{I}-\text{A}\right)}^{-1}\text{B}+\text{D}.$`

• 对于连续时间方程组，状态空间矩阵通过

`$\begin{array}{l}\stackrel{˙}{x}=\text{A}\text{\hspace{0.17em}}x+\text{B}\text{\hspace{0.17em}}u\\ y=\text{C}\text{\hspace{0.17em}}x+\text{D}\text{\hspace{0.17em}}u.\end{array}$`

与状态向量 x、输入 u 和输出 y 相关。

传递函数是方程组的冲激响应的拉普拉斯变换。可以按状态空间矩阵表示形式将其表示为

`$\text{H}\left(s\right)=\text{C}{\left(s\text{I}-\text{A}\right)}^{-1}\text{B}+\text{D}.$`

## 另请参阅

(Signal Processing Toolbox) | (Signal Processing Toolbox) | (Signal Processing Toolbox) | (Signal Processing Toolbox) | (Signal Processing Toolbox) | (Signal Processing Toolbox)