solving a dynamic equation

조회 수: 21 (최근 30일)
sam
sam 2022년 11월 26일
답변: Davide Masiello 2022년 11월 27일
Hi everyone, I want to solve the following equationinMATLAB, namely obtain u and u'.
m*u''(t)=sign(u'(t))*c*m*g-m*u''g(t)
u''g=[0;0.002,0.003,0.004,0.001,-0.01,-0.02,0]
m=2kg,c=0.1,g=9.81
I would be really grateful if someone could help me to solve this eqution with ODE45.
Thak you very much
  댓글 수: 1
Sam Chak
Sam Chak 2022년 11월 26일
If g is gravitational acceleration, then what is g(t) in this product term m·u"·g(t)?
Mass m times Acceleration u" times a function g(t)?

댓글을 달려면 로그인하십시오.

답변 (1개)

Davide Masiello
Davide Masiello 2022년 11월 27일
Hi @sam - you did not provide enough info for us to try and give a complete answer, but I did some guessing and came up with a solution nonetheless.
I am assuming that the term u''g(t) appearing in the equation and the array u''g are the same thing. That is to say that the term u''g(t) is given as a discrete time function.
You did not specify initial conditions and time span, so I made them up.
I am assuming that the body starts at a height of 50 and velocity 0, and that it falls for 10 s.
The problem can be solved in the following way.
m = 2;
c = 0.1;
g = 9.81;
tspan = [0,10];
u2g = [0,0.002,0.003,0.004,0.001,-0.01,-0.02,0];
f_u2g = @(x) interp1(linspace(tspan(1),tspan(end),length(u2g)),u2g,x); % interpolation to get continuous function from discrete data
[t,u] = ode45(@(t,u)model(t,u,m,c,g,f_u2g),tspan,[50,0]);
plot(t,u(:,1),t,u(:,2))
legend('u','u''')
function dudt = model(t,u,m,c,g,f_u2g)
dudt(1,1) = u(2);
dudt(2,1) = sign(u(2))*c*g-f_u2g(t);
end

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by