How to find position function with acceleration function using matlab
30 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have an equation:
x1_doubledot = -((k1+k2)/m1)*x1 + (k2/m1)*x2
where x1_doubledot is acceleration. I want to find the position function of this equation, what code should I use for MATLAB? Thank you
1 commentaire
Stephen23
le 18 Oct 2022
Modifié(e) : Stephen23
le 18 Oct 2022
Original question retrieved from Google Cache:
How to find position function with acceleration function using matlab
I have an equation:
x1_doubledot = -((k1+k2)/m1)*x1 + (k2/m1)*x2
where x1_doubledot is acceleration. I want to find the position function of this equation, what code should I use for MATLAB? Thank you
Réponses (2)
John D'Errico
le 29 Sep 2022
Modifié(e) : John D'Errico
le 29 Sep 2022
Just knowing the acceleration is meaningless, UNLESS you know how long the acceleration was in force. Next, acceleration is a vector thing. so you might hve x,y, nd z accelerations, all happening at once. If all you know is ONE acceleration, you can only infer position in one dimension.
Regardless, in order to compute position from acceleration, you compute the velocity first. So integrating acceleration gives you velocity, BUT only if you know the initial velocity. Otherwise, all you can infer is a change in velocity.
So use cumtrapz to integrate acceleration as a function of time, to get velocity. Then add in the initial velocity. Something like:
x1_dot = v0 + cumtrapz(t,x1_doubledot);
Then use cumtrapz again. But again, you need to know the initial position, otherwise all you can infer is a relative diplacememt.
x1 = x0 + cumtrapz(t,x1_dot);
And if your data lives in two or three dimensions, then you need to do all of this for each dimension.
0 commentaires
Sam Chak
le 18 Oct 2022
Modifié(e) : Sam Chak
le 18 Oct 2022
This ordinary differential equation is a linear type. So, it is actually a kind of eigenvalue/eigenvector problem.
If it is difficult to follow, the try using the dsolve() command. The position is given by the xSol(t).
syms x(t)
k1 = 3;
k2 = -2;
m1 = 1;
eqn = diff(x,t,2) == - ((k1 + k2)/m1)*x + (k2/m1)*diff(x,t);
Dx = diff(x,t);
cond = [x(0)==1, Dx(0)==0]; % initial condition
xSol(t) = dsolve(eqn, cond)
fplot(xSol, [0 10]), grid on
xlabel('t'), ylabel('x(t)'), title('Position')
0 commentaires
Voir également
Catégories
En savoir plus sur Symbolic Math Toolbox 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!