本人初学MATLAB,要求用M函数建立图中这些方程(部分)
,我自己写的函数是
syms F12x F12y F32x F32y F43x F43y M12 ac2x ac2y ac3x ac3y D2(r1) alpha2 alpha3
r2=0.0575;
r3=0.21;
m2=13.318;
m3=1.4762;
rc2=0.250;
rc3=0.850;
I2=0.8324;
I3=1.0666;
[F12x,F12y,F32x,F32y,F43x,F43y,M12,ac2x,ac2y,ac3x,ac3y,D2(r1),alpha2,alpha3]=solve(F12x+F32x=m2*ac2x,F12y+F32y=m2*ac2y,-F32x*r2*sin(theta2)+F32y*r2*cos(theta2)+M12=I2*alpha2,-F32x+F43x=m3*ac3x,-F32y+F43y=m3*ac3y,-F43x*(r3-rc3)*sin(theta3)+F43y*(r3-rc3)*cos(theta3)-F32x*rc3*sin(theta3)+F32y*rc3*cos(theta3)=I3*alpha3,-F43x+Fext=m4*D2(r1),-F43y+F14y=0,r1=r2*cos(theta2)+r3*cos(theta3),r2*sin(theta2)+r3*sin(theta3)=0,D2(r1)+r3*sin(theta3)*alpha3+r2*sin(theta2)*alpha2=-r2*cos(theta2)*omega2^2-r3*cos(theta3)*omega3^2-r3*cos(theta3)*alpha3+r2*cos(theta2)*alpha2=-r2*sin(theta2)*omega2^2-r3*sin(theta3)*omega3^2,ac2x=-rc2*alpha2*sin(theta2)-rc2*omega2^2*cos(theta2),ac2y=rc2*alpha2*cos(theta2)-rc2*omega2^2*sin(theta2),ac3x=-rc3*alpha3*sin(theta3)-rc3*omega3^2*cos(theta3)-r2*alpha2*sin(theta2)-r2*omega2^2*cos(theta2),ac3y=-rc3*alpha3*cos(theta3)-rc3*omega^2*sin(theta3)+r2*alpha2*cos(theta2)-r2*omega2^2*sin(theta2));
end
结果运行出来很多错误
s10: Parse error at '=' appears to be invalid MATLAB syntax10: Parse error at '=' appears to be invalid MATLAB syntax10: Parse error at '=' appears to be invalid MATLAB syntax10: Parse error at '=' appears to be invalid MATLAB syntax10: Parse error at '=' appears to be invalid MATLAB syntax10: Parse error at '=' appears to be invalid MATLAB syntax10: Parse error at '=' appears to be invalid MATLAB syntax10: Parse error at '=' appears to be invalid MATLAB syntax10: Terminate line with semicolon to suppress output10: Parse error at '=' appears to be invalid MATLAB syntax10: Parse error at '=' appears to be invalid MATLAB syntax10: Terminate line with semicolon to suppress output10: Terminate line with semicolon to suppress output10: Terminate line with semicolon to suppress output10: Parse error at ')' appears to be invalid MATLAB syntax
求教高手告诉我哪里有问题啊
因为我要建立一个M文件运行这个仿真,我按照你给的格式在后面加了14个要求的位置未知量......*alpha2*cos(theta2)-r2*omega2^2*sin(theta2)',F12x,F12y,F32x,F32y,F43x,F43y,F14x,M12,D2(r1),alpha3,ac2x,ac2y,ac3x,ac3y);,
其中D2(r1)这里应该代表二阶导数,因为我要运行一个simulink仿真,如图
看起来你是想接一个二阶振动方程,如果是一般求解推荐使用ode45等函数快捷。我没有具体做过仿真,只是见过相关资料。推荐参考书《基于MATLAB/Simulink的系统仿真技术与应用》很实用。
另外变量的导数貌似不是使用D2(r1) 的表达方式吧,我常用的是:diff()等。
能力不足帮不上太大的忙,不好意思哈