这里有趣的问题。在我们学校的Windows服务器上,Matlab可以很好的执行下面代码中的place函数,并返回一个分配给变量K的1x4矩阵。但是,Linux服务器和我的个人电脑(Windows 8.1)上的Matlab都返回多个错误。状态空间矩阵的解是正确的。我也尝试过简单地创建一个具有 Double 类型而不是符号矩阵的值的 A 和 B 矩阵,但无济于事。错误如下:
Error using symengine
Cannot prove '(0.00000000000011152837950971767051666806677642 < 5.0227916840119976230900756087285) < 2' literally. To test the statement
mathematically, use isAlways.
Error in sym/logical (line 360)
X = mupadmex('symobj::logical',A.s,9);
Error in sym/any (line 417)
X = any(logical(A));
Error in place (line 77)
if any(mult>m)
我试图执行的相关代码是这样的:
syms theta thetadot y ydot u s;
I2 = 0.05;
I1 = 0.2;
m2 = 2;
r = 0.11;
a = 0.1;
g = 9.81;
x0 = [20 * pi / 180 0.2 0 0];
W = [I1 + I2 + m2 * (y^2 + r^2) m2 * r + I2 / a; m2 * r + I2 / a m2 + I2 / a^2];
qdd = W^(-1) * ([u; 0] - (m2 * [2*y*thetadot*ydot; -y*thetadot^2] - m2*g* [r*sin(theta) + y*cos(theta); sin(theta)]));
qd = [thetadot; ydot];
xdot = [qd; qdd];
eq = [0 0 0 0 0 ];
x3bytheta = subs(diff(qdd(1), theta), {theta, y, thetadot, ydot, u}, eq);
x3byy = subs(diff(qdd(1), y), {theta, y, thetadot, ydot, u}, eq);
x3bythetadot = subs(diff(qdd(1), thetadot), {theta, y, thetadot, ydot, u}, eq);
x3byydot = subs(diff(qdd(1), ydot), {theta, y, thetadot, ydot, u}, eq);
x4bytheta = subs(diff(qdd(2), theta), {theta, y, thetadot, ydot, u}, eq);
x4byy = subs(diff(qdd(2), y), {theta, y, thetadot, ydot, u}, eq);
x4bythetadot = subs(diff(qdd(2), thetadot), {theta, y, thetadot, ydot, u}, eq);
x4byydot = subs(diff(qdd(2), ydot), {theta, y, thetadot, ydot, u}, eq);
x3byu = subs(diff(qdd(1), u), {theta, y, thetadot, ydot, u}, eq);
x4byu = subs(diff(qdd(2), u), {theta, y, thetadot, ydot, u}, eq);
A = [0 0 1 0; 0 0 0 1; x3bytheta x3byy x3bythetadot x3byydot; x4bytheta x4byy x4bythetadot x4byydot];
B = [0; 0; x3byu; x4byu];
K = place(vpa(A, 3), vpa(B, 3), [-1, -2, -1+2j, -1-2j]);