一、系统转换方程
系统的转换方程 G(s) 和回馈矩阵 K(s) 由下2式给出:
二、从转换方程推出系统矩阵A和B
from scipy.signal import tf2ss
# Convert to state-space representation
A, B, C, D = tf2ss([1], [1, -2, 1])
print("A matrix:", A)
print("B matrix:", B)
print("C matrix:", C)
print("D matrix:", D)
函数定义(版权:scipy库):
def tf2ss(num, den):
r"""Transfer function to state-space representation.
Parameters
----------
num, den : array_like
Sequences representing the coefficients of the numerator and
denominator polynomials, in order of descending degree. The
denominator needs to be at least as long as the numerator.
Returns
-------
A, B, C, D : ndarray
State space representation of the system, in controller canonical
form.
Examples
--------
Convert the transfer function:
.. math:: H(s) = \frac{s^2 + 3s + 3}{s^2 + 2s + 1}
>>> num = [1, 3, 3]
>>> den = [1, 2, 1]
to the state-space representation:
.. math::
\dot{\textbf{x}}(t) =
\begin{bmatrix} -2 & -1 \\ 1 & 0 \end{bmatrix} \textbf{x}(t) +
\begin{bmatrix} 1 \\ 0 \end{bmatrix} \textbf{u}(t) \\
\textbf{y}(t) = \begin{bmatrix} 1 & 2 \end{bmatrix} \textbf{x}(t) +
\begin{bmatrix} 1 \end{bmatrix} \textbf{u}(t)
>>> from scipy.signal import tf2ss
>>> A, B, C, D = tf2ss(num, den)
>>> A
array([[-2., -1.],
[ 1., 0.]])
>>> B
array([[ 1.],
[ 0.]])
>>> C
array([[ 1., 2.]])
>>> D
array([[ 1.]])
"""
程序输出:
A matrix: [[ 2. -1.]
[ 1. 0.]]
B matrix: [[1.]
[0.]]
C matrix: [[0. 1.]]
D matrix: [[0.]]
三、奈奎斯特图的绘制(使用MATLAB)
开环系统: 需要矩阵A, B, C, D
A = [2 -1; 1 0];
B = [1; 0];
C = [0 1];
D = 0;
s = tf('s');
ltf = ss(A, B, C, D);
figure;
nyquist(ltf);
grid on;
奈奎斯特图像:
闭环系统: 需要矩阵A, B, K
% Define the system matrices A and B
A = [2, -1; 1, 0];
B = [1; 0];
% Define the closed-loop gain function K(s)
numerator = [1500, -100];
denominator = [1, 30, 400];
K = tf(numerator, denominator);
% Create the closed-loop system
sys_cl = ss(A, B, eye(2), 0); % Assuming direct feedback
% Plot the Nyquist diagram
nyquist(sys_cl * K);
grid on;
奈奎斯特图像(主要关注通道2):