calculate the speed and position of the rocket and plot a graph of velocity vs time and altitude vs time
25 views (last 30 days)
Show older comments
Kimberley Pereira
on 13 Apr 2020
Answered: MUTHUKUMAR K
on 7 Nov 2022
1::: m*dV/dt= v_e*dm/dt -G*Mm/r^2 -0.5ρAV^2 C_d
2::: ρ=1.225*10^(-3h/50000)
i need to plot a graph of speed against time using equation 1. I am not allowed to use matlab function to solve the differential eqaution such as ode45, or dsolve instead i need to use explicit method. Also I need to plot a graph of altitude against time
This is my code so far
I am stuck and don't know what to do next? please help
clear
speed(1)=v;
speed_2(1)=v;
height(1)=h;
height_2(1)=h;
mass(1)=m_0;
radii(1)=R;
rho(1)=rho_0;
drag(1)=D;
thrust(1)=T;
weight(1)=w_0;
%CONSTANTS
G=6.67408*10^(-11);
M=5.9722*10^(24);
R=6371000;
gravity= 9.81;
A= 75;
c_d=0.4;
v_e=4500;
dt=1;
m_e=54000;
m_0=894000;
dm=5000;
dm_2=0;
tNfuel=(m_0/m_e)/dm;
%INITAL VALUE AT t=0
v=0;
r=R;
h=0;
rho_0=1.225;
D=0;
T=0;
w_0=(G*M*m_0)/(R^2);
%GIVEN EQUATION
for i=2:lenght(t)
rho(i)=1.225(1)*10^((-3*h(i-1)/50000);
if m(i-1)>=m_e
m(i)=m(i-1)- dm*dt;
else
m(1)=m(i-1);
dm=0;
end
end
plot(v,t)
0 Comments
Accepted Answer
Ameer Hamza
on 13 Apr 2020
It seems like you are trying to use Euler's method. If you are confused about implementing the numerical ODE solver from scratch, then look at the code of ode1.m, which is an old MATLAB solver based on the Euler method: https://www.mathworks.com/matlabcentral/answers/98293-is-there-a-fixed-step-ordinary-differential-equation-ode-solver-in-matlab-8-0-r2012b. It is no longer available in MATLAB. You can adapt according to your ODEs.
0 Comments
More Answers (2)
Image Analyst
on 19 Apr 2020
My attached demo gives you all kinds of control over initial parameters, and computes just about every possible thing you could want to know about a projectile. Numerous graphs are plotted. Adapt as needed.
0 Comments
MUTHUKUMAR K
on 7 Nov 2022
%CONSTANTS
G=6.67408/10^11;
M=5.9722*10^24;
R=6371000;
gravity= 9.81;
A= 75;
c_d=0.4;
v_e=4500;
dt=1;
m_e=54000;
m_0=894000;
dm=5000;
dm_2=0;
tNfuel=(m_0/m_e)/dm;
%INITAL VALUE AT t=0
v=0.3;
r=R;
h=0;
rho_0=1.225;
D=0;
T=0;
w_0=(G*M*m_0)/(R^2);
t=6;
%clear
speed(1)=v;
speed_2(1)=v;
height(1)=h;
height_2(1)=h;
mass(1)=m_0;
radii(1)=R;
rho(1)=rho_0;
drag(1)=D;
thrust(1)=T;
weight(1)=w_0;
%GIVEN EQUATION
for i=2:length(t)
b=(-3*h(i-1)/50000)
rho(i)=1.225*(1)*10^b;
if b(i-1)>=m_e
G(i)=U(i-1)-(dm*dt);
else
M(1)=M(i-1);
dm=0;
end
plot(v,t(i,:));
hold on
end
ax=gca;
ax.XAxisLocation='origin'
ax.YAxisLocation='origin'
xlabel('v');
ylabel('t');
title('V-T');
grid on;
grid minor;
hold off;
0 Comments
See Also
Categories
Find more on Dates and Time 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!