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!