ODE45: Adjusting the parameters in the state equations

1 次查看(过去 30 天)
I would like to vary a parameter (o) in my ODE45 for a clutch mechanism. The clutch would enagaged when the velocity and acceleration are in the same direction (accel/Vel>0) and disengaged when the (accel/vel < 0). I am not sure how to implement the loop in the fuction file.
function [dy] = SS(t,y);
dy = NaN(4,1);
t = [0:0.001:4];
ug = 0.5*sin(pi*t/0.6); %input loading
plot(t,ug,'-r*');
hold on;
ug(t>0.5)=0; % values where t>0.5 will be assigned to zero
plot(t,ug,'-co');
legend('full sine load','desired load')
uu=1*ug;
u=1;
v=0.5;
o=0.5;
e1=0;
e2=0;
w1=2*pi;
w2=6.666*pi;
if dy(1)*dy(2)<0 %%% need the velocity and floor accleration in the same direction
o=0
else
o=0.5;
end
dy(1)= y(2);
dy(2)=(1/u)*(-1*(1-v)*uu-2*e1*w1*y(2)+2*v*e2*w2*y(4)-w1*w1*y(1)+v*w2*w2*y(3));
dy(3) = y(4);
dy(4) = (1/u)*((-o*uu)+2*e1*w1*y(2)-2*(1+o)*e2*w2*y(4)+w1*w1*y(1)-(1+o)*w2*w2*y(3));
  3 个评论
Komal Rajana
Komal Rajana 2020-1-7
编辑:Komal Rajana 2020-1-7
Hi David,
Would it be possible to specify the 'value' in the event as an acceleration instead of the state space variables (positions and velocity)?. I need my clutch system to engaed when the acceleration and velocity are in the same direction....
thanks
David Goodmanson
David Goodmanson 2020-1-8
编辑:David Goodmanson 2020-1-8
This should be possible. The event is activated when the value of a function of the state vector [y; y'] reaches zero. Since (by the differential equation you are solving) the acceleration is a function of [y,y'] (and possibly t), you should be able to create the correct function to be detected. Doing 'type ballode' or (riskier, but with better fomatting) 'edit ballode', will bring up an example of how to detect an event and restart the integration with modified initial conditions and, potentially, with an altered ODE.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

标签

产品


版本

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by