Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Matlab 获得;第二个参数必须是一个变量或一个非负整数,指定微分的数目;错误_Matlab_Diff - Fatal编程技术网

Matlab 获得;第二个参数必须是一个变量或一个非负整数,指定微分的数目;错误

Matlab 获得;第二个参数必须是一个变量或一个非负整数,指定微分的数目;错误,matlab,diff,Matlab,Diff,我试图象征性地获得Euler-Lagrange方程,但我一直得到“第二个参数必须是变量或指定微分数的非负整数”错误。它与方程的第一项(dL/dx_点)一起出现。我不知道我做错了什么。感谢您的帮助。谢谢 syms m0 m1 m2 I1 I2; syms x(t) theta1(t) theta2(t); syms L1 L2; syms F(t); syms g T0 = 0.5*m0*diff(x(t),t)^2; %Kinetic energy of mass T1 = 0.5*m1*((

我试图象征性地获得Euler-Lagrange方程,但我一直得到“第二个参数必须是变量或指定微分数的非负整数”错误。它与方程的第一项(dL/dx_点)一起出现。我不知道我做错了什么。感谢您的帮助。谢谢

syms m0 m1 m2 I1 I2;
syms x(t) theta1(t) theta2(t);
syms L1 L2;
syms F(t);
syms g
T0 = 0.5*m0*diff(x(t),t)^2; %Kinetic energy of mass 
T1 = 0.5*m1*((diff(x(t),t)+0.5*L1*diff(theta1(t),t)*cos(theta1(t)))^2+(L1*diff(theta1(t),t)*sin(theta1(t)))^2)+0.5*I1*diff(theta1(t),t)^2; %Kinetic energy of pendulum 1 
T2 = 0.5*m2*((diff(x(t),t)+L1*diff(theta1(t),t)*cos(theta1(t))+0.5*L2*diff(theta2(t),t)*cos(theta2(t)))^2+(L1*diff(theta1(t),t)*sin(theta1(t))+0.5*L2*diff(theta2(t),t)*sin(theta2(t)))^2)+0.5*I2*diff(theta2(t),t)^2; %Kinetic energy of pendulum 2
T = T0+T1+T2; % Total kinetic energy
U0 = 0; %Potential energy of mass
U1 = m1*g*0.5*L1*cos(theta1(t)); %Potential energy of pendulum 1
U2 = m2*g*(L1*cos(theta2(t))+0.5*L2*cos(theta2(t))); %Potential energy of pendulum 2
U = U0+U1+U2; %Total potential energy
L = T-U; %Lagrangian of system
dL_dx_dot = diff(L,diff(x(t),t));
dL_dx = diff(L,x);
diff(dL_dx_dot,t) - dL_dx == F(t)