ODE to solve for density
Mostrar comentarios más antiguos
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
Respuesta aceptada
Más respuestas (1)
Bjorn Gustavsson
el 2 de Mzo. de 2021
1 voto
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.
Categorías
Más información sobre Gravitation, Cosmology & Astrophysics en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
