1

equationsToMatrix我正在尝试使用该函数找到倒置(一件)摆的状态空间模型。我正在使用以下代码:

%Declaration of Variables
syms x(t) t M m ddx(t) l th(t) ddth(t) dth(t) b1 b2 dx(t) F(t) I

%Nonlinear Equations
eqn1=eq((I+m*l^2)*ddth+m*l*cos(th)*ddx-m*g*l*sin(th)+b2*dth,0)
eqn2=eq((M+m)*ddx+m*l*cos(th)*ddth-m*l*sin(th)*(dth)^2+b1*dx,F)

%Linear Equations
eqn1L=subs (eqn1,[cos(th),sin(th(t)),dth(t)^2],[1,th(t),0])
eqn2L=subs (eqn2,[cos(th),sin(th(t)),dth(t)^2],[1,th(t),0])

%Finding State Space Model
[A,B]=equationsToMatrix([eqn2L,eqn1L],[x(t),dx(t),th(t),dth(t)])
C=[1 0 0 0;0 1 0 0;0 0 1 0;0 0 0 1];
D=[0;0;0;0];

sys = ss(A,B,C,D)

MATLAB 引发以下错误:

sym.getEqnsVars使用>时出错checkVariables(第 92 行)
第二个参数必须是符号变量的向量。

错误sym.getEqnsVars(第 54 行)
checkVariables(vars);

错误sym/equationsToMatrix(第 55 行)
[eqns,vars] = sym.getEqnsVars(argv{:});

错误Linearization_Test(第 10 行)
[A,B]=equationsToMatrix([eqn2L,eqn1L],[x(t),dx(t),th(t),dth(t)])

如何解决此错误?

4

1 回答 1

1

您应该将变量替换为没有时间依赖性的变量:

syms x_ dx_ th_ dth_
X = [x(t),dx(t),th(t),dth(t)];
X_ = [x_,dx_,th_,dth_];
[A,B]=equationsToMatrix(subs([eqn2L,eqn1L], X, X_),X_)
于 2017-09-08T13:39:06.823 回答