ODE to solve for density
古いコメントを表示
Hi,
I'm currently trying to calculate air density which involves solving an ODE for altitude. I have plotted a graph for it, I get the right shape but the axis and numbers are wrong. The first figure is what I get for my output, whereas the second is the correct one (using the line vector). Can anybody help me? Much appreciated


[h,p]=ode45(@p_prime,[0 7.5],0);
plot(p,h)
ylabel('Altitude (km)')
xlabel('Air density (kg/m^3)')
function dp=p_prime(h,p)
p0=1.225
hscale=7.5
dp=(p0*exp(-h/hscale))
end
採用された回答
その他の回答 (1 件)
Bjorn Gustavsson
2021 年 3 月 2 日
1 投票
Your ODE is not correct for the pressure-variation. What you have in the p_prime function is closer to the solution of the pressure-balance. If you go back to the book you'll see something like this:

That is what you should have in the p_prime-function that you then integrate with altitude.
カテゴリ
ヘルプ センター および File Exchange で Gravitation, Cosmology & Astrophysics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
