主要内容

缩放状态空间模型以最大化精度

该示例表明,正确的状态空间模型适当缩放对于准确性至关重要,并提供了自动和手动重新缩放工具的概述。

为什么比例很重要

A state-space model is well scaled when the entries of the A,B,C matrices are homogeneous in magnitude and the model characteristics are insensitive to small perturbations of A,B,C (in comparison to their norms). By contrast, a model is poorly scaled when A,B,C have both small and large entries and the model characteristics are sensitive to the small entries.

混合时间尺度或单位尺度可能会产生尺寸不佳的模型。使用此类模型会导致严重的准确性和令人困惑的结果。为了防止这些问题,通常有必要恢复状态向量,即将每个状态乘以一定的缩放因素,以降低模型的数值范围和灵敏度。

缩放率差会影响大多数频域计算的准确性。最先进的算法在很大程度上依赖正交状态坐标转换,这种转换引入了秩序错误EPS(the machine precision) times the norms of A,B,C. While such errors are usually negligible, they can become dominant when A,B,C are poorly scaled. To see this phenomenon, load the following example:

loadnumdemoanil

anil米odel is a state-space realization of a 20-th order transfer function with most of its dynamics between 1e3 and 1e5 rad/s. The coefficients of the A matrix range between 1 and 1e80 in magnitude. To simulate the effect of orthogonal transformations applied to this model, generate a random orthogonal matrixU并使用SS2SSto perform the corresponding change of state coordinates:

[u,junk] = qr(randn(20));anil2 = ss2ss(anil,u);%执行状态坐标转换U

数学上,anilanil2具有相同的频率响应。但是,从数值上讲,Bode响应的anilanil2are very different:

Bode(anil,'b',anil2,'r-') legend('Original','After Orthogonal Transformation','地点','西南')

This example shows that for poorly scaled models, even orthogonal transformations can be unsafe and destroy accuracy.

灵敏度最小化缩放

对于从物理学中得出的简单模型,您可以通过仔细选择单元来避免缩放问题,以减少小系数和大型系数之间的传播。但是,对于更复杂的模型,找到适当的缩放是具有挑战性的。诸如A矩阵的平衡等临时方案(请参阅平衡) are often useful but sometimes harmful.

Control System Toolbox™软件提供了高级缩放算法,可将模型对A,B,C的小扰动的敏感性最小化,与其规范成比例。这有助于最大程度地提高计算频率响应,ZPK表示等的精度。预定命令是这些缩放算法的门户。例如,您可以使用预定缩放anil上面使用的模型:

scaled_anil =预定(anil);

这coefficients of the A matrix now range from 1e3 to 3e7 instead of 1 to 1e80. Apply the orthogonal transformationU与缩放模型并比较Bode响应:

scaled_anil2 = ss2ss(scaled_anil,u);bode(scaled_anil,'b',scaled_anil2,'r-') legend(“缩放模型”,'After Orthogonal Transformation','地点','西南')

这Bode responses match closely now. Scaling has made orthogonal transformations safe again and you can expect good accuracy from computations involving this scaled model.

Automatic Scaling

控制系统工具箱软件中的大多数算法会自动缩回状态空间模型,以防止灾难性的准确性丧失。结果,您主要与扩展问题隔绝。例如,Bode命令会自动缩放传入模型,以便它可以安全地执行正交转换以加快频率响应计算。因此,无需使用预定Bode除非您需要有关计算Bode响应的相对准确性的详细信息。

手动缩放

虽然控制系统工具箱缩放算法在没有用户干预的情况下处理大多数模型,但在罕见的情况下,在整个频率范围内无法实现良好的精度,并且该算法必须在一个频带中以良好的精度来换取另一个频段的准确性,以使其在另一个频段中的准确性。在这种情况下,发出警告以提醒您潜在的不准确性。为了说明这种行为,请加载下一个示例并绘制其Bode响应:

loadnumdemo警告bode(warnsys,{1e-3,1e6}),网格

Note the warning issued by theBodecommand. This 17-th order model has dynamics near 0.01 rad/s and between 1e3 and 1e6 rad/s, separated by a 300dB gain drop. You can eliminate the warning by narrowing down the frequency range of interest, for example, to [10,1e6] rad/s:

bode(warnsys,{10,1e6}),网格

This instructs the algorithm to maximizes accuracy in the interval [10,1e6]. You can also investigate the underlying accuracy tradeoff by typing:

>> prescale(warnsys)

此命令打开下面所示的交互式缩放工具。将频率轴限制为1E-2至1E6。顶部图显示了频率响应幅度,底部图显示:

  • 计算响应的相对准确性而无需缩放(红色)

  • 这relative accuracy of the computed response with scaling (blue)

  • 这best achievable accuracy when using independent scaling at each frequency (brown)

Any relative accuracy value greater than one signals poor accuracy.

In this example, the Relative Accuracy plot shows that the scaling algorithm achieved good accuracy in the [1e3,1e6] frequency band at the expense of accuracy at low frequencies. If you only care about the frequency band [1e-3,1], you can override this default range selection and manually specify the frequency band where you want maximum accuracy. For example, enter [1e-3,1] in the edit boxes next to最大化频带的精度:

This action updates the bottom plot and the relative accuracy of the scaled model (blue curve) is now best near 1e-2 rad/s, but is significantly worse in the [1e3,1e6] band.

这缩放Property of State-Space Models

这State-Space (@ss) object has a缩放属性要指示何时缩放模型。它的默认值是false。这预定命令将此属性设置为真的:

sys = prescale(anil); sys.Scaled
ans =逻辑1

因为缩放算法跳过了缩放= true, you can manually set the缩放property to真的when your model is well scaled and you want to eliminate the small overhead associated with scaling. If you want more control over where accuracy is maximized, you can also explicitly scale your model before using it:

sys = prescale(warnsys,{10,1e6});博德(SYS)

Here警告is scaled with emphasis on the frequency range [10,1e6] andBodedoes not attempt to rescale the resulting modelsys(不再警告)。

结论

Proper scaling of state-space models is important to achieve accurate results. Most Control System Toolbox commands take care of scaling automatically. You are alerted when accuracy may be compromised and you can easily correct the problem by specifying the frequency band of interest.