How to find position function with acceleration function using matlab
30 次查看(过去 30 天)
显示 更早的评论
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 个评论
Stephen23
2022-10-18
编辑:Stephen23
2022-10-18
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
回答(2 个)
John D'Errico
2022-9-29
编辑:John D'Errico
2022-9-29
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 个评论
Sam Chak
2022-10-18
编辑:Sam Chak
2022-10-18
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Symbolic Math Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!