Filter löschen
Filter löschen

solving a dynamic equation

25 Ansichten (letzte 30 Tage)
sam
sam am 26 Nov. 2022
Beantwortet: Davide Masiello am 27 Nov. 2022
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 Kommentar
Sam Chak
Sam Chak am 26 Nov. 2022
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)?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Davide Masiello
Davide Masiello am 27 Nov. 2022
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

Kategorien

Mehr zu Symbolic Math Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by