我试图用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)])
如何解决此错误?
发布于 2017-09-08 13:39:06
应该将变量替换为没有时间依赖性的变量:
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_)https://stackoverflow.com/questions/46116752
复制相似问题