solving a dynamic equation

27 ビュー (過去 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 Center および File ExchangeSymbolic Math Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by