Simulate shock with spring ODE
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Eugène PLANTEUR
il 7 Mar 2020
Risposto: Eugène PLANTEUR
il 10 Mar 2020
Hello everyone !
I was given the project to compute and simulate a shock between two particles, using a spring differential equation. It's a 2 dimension problem, so there are eight equations to solve:

Where
and
are the initial velocities of the first particle (the second one is not moving at the beginning) and
are constants. But when I run my code:
SystemInit=[0,0,30,30,2,2,0,0];
time=[0,100];
[t,y]=ode45(@(t,y) odefunc(t,y,a1,a2,K1x,K1y,K2x,K2y),time,SystemInit);
With my odefunc being:
function u=odefunc(t,y,a1,a2,K1x,K1y,K2x,K2y)
u=zeros(8,1);
u(1)=y(1);
u(2)=y(2);
u(3)=y(3);
u(4)=y(4);
u(5)=a1*y(5)+K1x;
u(6)=a1*y(6)+K1y;
u(7)=a2*y(7)+K2x;
u(8)=a2*y(8)+K2y;
end
I get a sort of exponential law for all the components of my y vector (excepted for the two firsts). So am I doing it right ? We've just started learning how to compute differential equations in Matlab, so there might be something I didn't manage to figure out.
I hope I've been clear enough.
13 Commenti
Risposta accettata
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
