赞
踩
出错代码如下:
syms s;
% Gnom matrix
g11 = 13.8 / (0.16 * s + 1);
g12 = -0.05 / (0.1 * s + 1);
g21 = 0.1 / (0.3 * s + 1);
g22 = 4.25 * s / (0.84 * s - 1);
Gnom = [g11 g12; g21 g22];
w1 = makeweight(0.2, 35, 9);
w2 = makeweight(0.25, 40, 8);
W = blkdiag(w1, w2);
Delta_1 = ultidyn('Delta_1', [1 1]);
Delta_2 = ultidyn('Delta_2', [1 1]);
Delta = blkdiag(Delta_1, Delta_2);
G = Gnom * (eye(2) + Delta * W); // 出错:unable to convert 'uss' to 'sym'
报错截图:
解决方法及解释:将符号变量s的定义从“syms s”改成“s = tf(‘s’)”,tf = transfer function,系统的转换函数。
修正后的代码:
s = tf('s'); % syms s; % Gnom matrix g11 = 13.8 / (0.16 * s + 1); g12 = -0.05 / (0.1 * s + 1); g21 = 0.1 / (0.3 * s + 1); g22 = 4.25 * s / (0.84 * s - 1); Gnom = [g11 g12; g21 g22]; w1 = makeweight(0.2, 35, 9); w2 = makeweight(0.25, 40, 8); W = blkdiag(w1, w2); Delta_1 = ultidyn('Delta_1', [1 1]); Delta_2 = ultidyn('Delta_2', [1 1]); Delta = blkdiag(Delta_1, Delta_2); G = Gnom * (eye(2) + Delta * W);
注意: 将s的定义修改为s = tf(‘s’)虽然可以解决上述变量类型的报错,但这样一来,就无法通过det命令计算矩阵Gnom的行列式,会出现如下报错:
提示输入的参数类型不正确。还需将s = tf(‘s’)改回syms s。计算出的矩阵行列式值(用s表示):
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。