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!