calculate the speed and position of the rocket and plot a graph of velocity vs time and altitude vs time
8 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
Ameer Hamza
2020 年 4 月 13 日
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 件のコメント
その他の回答 (2 件)
Image Analyst
2020 年 4 月 19 日
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 件のコメント
MUTHUKUMAR K
2022 年 11 月 7 日
%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 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!