solving a dynamic equation

11 views (last 30 days)
sam on 26 Nov 2022
Answered: Davide Masiello on 27 Nov 2022
Hi everyone, I want to solve the following equationinMATLAB, namely obtain u and u'.
I would be really grateful if someone could help me to solve this eqution with ODE45.
Thak you very much
  1 Comment
Sam Chak
Sam Chak on 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)?

Sign in to comment.

Answers (1)

Davide Masiello
Davide Masiello on 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]);
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);


Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!