這裏有趣的問題。在我們學校的Windows服務器上,Matlab可以很好地執行下面的代碼中的函數,並返回一個分配給變量K的1x4矩陣。然而,我的個人計算機(Windows 8.1)上的Linux服務器和Matlab都會返回多個錯誤。狀態空間矩陣的解決方案是正確的。我也嘗試過簡單地創建一個類型爲Double的值而不是符號矩陣的A和B矩陣,但是無濟於事。這些錯誤如下:Matlab的地方功能錯誤
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]);
所有三個系統是否使用相同版本的控制系統工具箱?舊版本可能不支持與符號工具箱集成。 – TroyHaskin
兩個不起作用的是運行控制系統工具箱版本9.9和9.10。有趣的作品使用版本9.7。我發現我可以部分地解決這個問題,方法是將兩個矩陣按照如下方式加倍: K = place(double(A),double(B),[-1 -2 -1.5 + 2j -1.5-2j]); –