简体   繁体   English

状态空间系统给出不同的波特图然后传递函数矩阵

[英]State space system gives different bode plot then transfer function matrix

I have a state space system with matrices A,B,C and D. 我有一个状态空间系统,矩阵为A,B,C和D.

I can either create a state space system , sys1 = ss(A,B,C,D) , of it or compute the transfer function matrix , sys2 = C*inv(z*I - A)*B + D 我可以创建一个状态空间系统sys1 = ss(A,B,C,D) ,或者计算传递函数矩阵sys2 = C*inv(z*I - A)*B + D

However when I draw the bode plot of both systems, they are different while they should be the same. 然而,当我绘制两个系统的波特图时,它们是不同的,而它们应该是相同的。

What is going wrong here? 这里出了什么问题? Does anyone have a clue? 有人有线索吗? I know btw that the bodeplot generated by sys1 is correct. 我顺便说一句知道,所产生的bodeplot sys1是正确的。

The system can be downloaded here: https://dl.dropboxusercontent.com/u/20782274/system.mat 该系统可以在这里下载: https//dl.dropboxusercontent.com/u/20782274/system.mat

clear all;
close all;
clc;

Ts = 0.01;
z = tf('z',Ts);

% Discrete system
A = [0 1 0; 0 0 1; 0.41 -1.21 1.8];
B = [0; 0; 0.01];
C = [7 -73 170];
D = 1;

% Set as state space
sys1 = ss(A,B,C,D,Ts);

% Compute transfer function
sys2 = C*inv(z*eye(3) - A)*B + D;

% Compute the actual transfer function
[num,den] = ss2tf(A,B,C,D);
sys3 = tf(num,den,Ts);

% Show bode
bode(sys1,'b',sys2,'r--',sys3,'g--');

Edit: I made a small mistake, the transfer function matrix is sys2 = C*inv(z*I - A)*B + D , instead of sys2 = C*inv(z*I - A)*B - D which I did wrote done before. 编辑:我犯了一个小错误,传递函数矩阵是sys2 = C*inv(z*I - A)*B + D ,而不是sys2 = C*inv(z*I - A)*B - D我是之前做过写过。 The problem still holds. 问题仍然存在。


Edit 2: I have noticted that when I compute the denominator, it is correct. 编辑2:我已经注意到,当我计算分母时,它是正确的。

syms z;
collect(det(z*eye(3) - A),z)

Your assumption that sys2 = C*inv(z*I- A)*B + D is incorrect. 您假设sys2 = C*inv(z*I- A)*B + D不正确。 The correct equivalent to your state-space system (A,B,C,D) is sys2 = C*inv(s*I- A)*B + D . 与状态空间系统(A,B,C,D)的正确等效值是sys2 = C*inv(s*I- A)*B + D If you want to express it in terms of z , you'll need to invert the relationship z = exp(s*T) . 如果你想用z来表达它,你需要反转关系z = exp(s*T) sys1 is the correct representation of your state-space system. sys1是状态空间系统的正确表示。 What I would suggest for sys2 is to do as follows: 我建议sys2做的是:

sys1 = ss(mjlsCE.A,mjlsCE.B,mjlsCE.C,mjlsCE.D,Ts);
sys1_c = d2c(sys1);
s = tf('s');
sys2_c = sys1_c.C*inv(s*eye(length(sys1_c.A)) - sys1_c.A)*sys1_c.B + sys1_c.D;
sys2_d = c2d(sys2_c,Ts);

That should give you the correct result. 这应该会给你正确的结果。

Due to inacurracy of the inverse function extra unobservable poles and zeros are added to the system. 由于反函数的不精确性,额外的不可观察的极点和零点被添加到系统中。 For this reason you need to compute the minimal realization of your transfer function matrix. 因此,您需要计算传递函数矩阵的最小实现。

Meaning 含义

% Compute transfer function
sys2 = minreal(C*inv(z*eye(3) - A)*B + D);

What you are noticing is actually a numerical instability regarding pole-zero pair cancellations. 您注意到的实际上是关于极点 - 零对取消的数值不稳定性。 If you run the following code: 如果您运行以下代码:

A = [0, 1, 0; 0, 0, 1; 0.41, -1.21, 1.8] ;
B = [0; 0; 0.01] ;
C = [7, -73, 170] ;
D = 1 ;

sys_ss = ss(A, B, C, D) ;

sys_tf_simp = tf(sys_ss) ;

s = tf('s') ;
sys_tf_full = tf(C*inv(s*eye(3) - A)*B + D) ;

zero(sys_tf_simp)
zero(sys_tf_full)

pole(sys_tf_simp)
pole(sys_tf_full)

you will see that the transfer function formulated by matrices directly has a lot more poles and zeros than the one formulated by MatLab's tf function. 你会发现矩阵直接构造的传递函数比MatLab的tf函数制定的极点和零点多得多。 You will also notice that every single pair of these "extra" poles and zeros are equal- meaning that they cancel with each other if you were to simply the rational expression. 您还会注意到,这些“额外”极点和零点的每一对都是相等的 - 这意味着如果您只是理性表达式,它们会相互抵消。 MatLab's tf presents the simplified form, with equal pole-zero pairs cancelled out. MatLab的tf呈现简化形式,取消了相等的零极点对。 This is algebraically equivalent to the unsimplified form, but not numerically. 这在代数上等同于未简化的形式,但不是数字上的。

When you call bode on the unsimplified transfer function, MatLab begins its numerical plotting routine with the pole-zero pairs not cancelled algebraically. 当您在未简化的传递函数上调用波特时,MatLab开始其数值绘图例程,其中极点 - 零对未被代数取消。 If the computer was perfect, the result would be the same as in the simplified case. 如果计算机是完美的,结果将与简化案例中的结果相同。 However, numerical error when evaluating the numerator and denominators effectively leaves some of the pole-zero pairs "uncancelled" and as many of these poles are in the far right side of the s plane, they drastically influence the output behavior. 然而,在评估分子和分母时的数值误差有效地使一些极点 - 零对“未被消除”,并且由于这些极点中的许多极点位于s平面的最右侧,它们极大地影响输出行为。

Check out this link for info on this same problem but from the perspective of design: http://ctms.engin.umich.edu/CTMS/index.php?aux=Extras_PZ 查看此链接以获取有关此相同问题的信息,但从设计的角度来看: http//ctms.engin.umich.edu/CTMS/index.php?ox = Extras_PZ

In your original code, you can think of the output drawn in green as what the naive designer wanted to see when he cancelled all his unstable poles with zeros, but the output drawn in red is what he actually got because in practice, finite-precision and real-world tolerances prevent the poles and zeros from cancelling perfectly. 在原始代码中,您可以将绿色绘制的输出视为天真的设计师在用零取消所有不稳定的极点时想要看到的内容,但是用红色绘制的输出是他实际得到的,因为在实践中,有限精度和现实世界的公差可以防止极点和零点完全抵消。

Why is an unobservable / uncontrollable pole? 为什么是不可观察/不可控制的极点? I think this issue comes only because the inverse of a transfer function matrix is inaccurate in Matlab. 我认为这个问题只是因为传递函数矩阵的逆在Matlab中是不准确的。

Note: 注意:

  1. A is 3x3 and the minimal realization has also order 3. A是3x3,最小实现也是3阶。
  2. What you did is the inverse of a transfer function matrix, not a symbolic or numeric matrix. 你所做的是传递函数矩阵的逆,而不是符号或数字矩阵。

# Discrete system
Ts = 0.01;
A = [0 1 0; 0 0 1; 0.41 -1.21 1.8];
B = [0; 0; 0.01];
C = [7 -73 170];
D = 1;

z = tf('z', Ts)) # z is a discrete tf
A1 = z*eye(3) - A # a tf matrix with a direct feedthrough matrix A

# inverse it, multiply with C and B from left and right, and plus D
G = D + C*inv(A1)*B 

G is now a scalar (SISO) transfer function. G现在是标量(SISO)传递函数。

Without "minreal", G has order 9 (funny, I don't know how Matlab computes it, perhaps the "Adj(.)/det(.)" method). 没有“minreal”,G有9阶(有趣,我不知道Matlab如何计算它,也许是“Adj(。)/ det(。)”方法)。 Matlab cannot cancel the common factors in the numerator and the denominator, because z is of class 'tf' rather than a symbolic variable. Matlab不能取消分子和分母中的公因子,因为z是类'tf'而不是符号变量。

Do you agree or do I have misunderstanding? 你同意还是我有误解?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM