ODE45: Adjusting the parameters in the state equations
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
David Goodmanson
le 8 Jan 2020
Modifié(e) : David Goodmanson
le 8 Jan 2020
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.
Réponses (0)
Voir également
Catégories
En savoir plus sur Ordinary Differential Equations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!