Change in velocity equation with explicit method

4 次查看(过去 30 天)
Hello Everyone, I am new to MatLab, and looking for some help.
I have a code where I have 3600 time steps.
I am calculating change in mass of a rocket every step which is assumed to be constant (5000kg/s)
with this bit of a code
for n=2:length(t)
if M(n-1) >= mass_r;
M(n)=M(n-1)-dm*dt;
else
M(n)=mass_r-1;
end
end
I would like someone to help me to implement this equation in MatLab form
I tried using an explicit method but alot of errors just rainfalls on me.
Would appreciate any help.
  2 个评论
darova
darova 2020-3-29
Can you explain more? You have constant. What are you trying to calculate? What is V?
BioZ
BioZ 2020-3-29
编辑:BioZ 2020-3-29
V is the velocity, I can't express this equation using the explicit method discretisation.
The Idea is to calculate velocity on each time step.
For example if ve have this simple equation and initial value We can rewrite the equation and approximate it into this form and from this simply with the use of explicit method we can get this form which would work perfectly in MatLab.
I just need help with the equation stated in the question to rewrite it for use in MatLab by using explicit method discretisation to calculate velocity at each time step.
Would appreciate any help.

请先登录,再进行评论。

采纳的回答

Ameer Hamza
Ameer Hamza 2020-3-29
See this solution by using ode45
[t, V] = ode45(@dV, [0 300], 0);
plot(t,V)
function dVdt = dV(t, V)
G = 6.67408e-11;
M = 5.9722e24;
R = 6371e3;
A = 75;
Cd = 0.4;
me = 54000;
mo = 894000;
ve = 4500;
dmdt = 5000;
m_fuel = mo - me;
time_fuel = m_fuel/dmdt;
if t < time_fuel
m = mo - t*dmdt;
else
m = me;
end
dVdt = 1/m*(ve*dmdt - G*M*m/R^2 - 0.5*Cd*A*V^2);
end

更多回答(1 个)

darova
darova 2020-3-29
Here is what i think about this question
for n = 2:length(t)
if m(n-1) > me % if rocket has fuel
dm = 5000;
else
dm = 0; % no fuel, mass change=0
end
dV = (ve*dm - ...)/m % longformula for acceleration
m(n) = m(n) - dm*dt; % mass change
V(n) = V(n-1) + dV*dt;
end

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by