Using the 1976 US standard atmosphere model, this function returns pressure, denisity, temperature, and speed of sound at a given altitude. Works for both English and metric units.
Errors in calculated values. Don't Use
Accuracy is far below what is required in most aerospace classes now
I have no plans about maintaining this function or improving its accuracy. Brent Lewis has written a much better function that includes altitudes upwards of 2000 km and also molecular composition. This is excellent for both aircraft, rockets, and for use in atmospheric drag calculations.
If you require high degrees of accuracy and the more complete version, please use Mr. Lewis' software. However, if you need a simple function with lower accuracy, by all means, try mine.
Very rough values for constants and sloppy coding. Think about recoding.
Only covers less than 10% of the 1976 Standard Atmosphere(what is that half a star :) ). Might try the COMPLETE 1976 standard atmosphere. See ya in class(or the bar) Rich
Careful on the accuracy of this program, it is based on an obsolete atmosphere model
Also, I think line 112 should read:
"[TNew, PNew, RhoNew] = Gradient(H5, H6, TNew, PNew, RhoNew, L6)"
It would also be very helpful if the input were allowed to be a vector.
Needed to modify it to work with my version of matlab,
[mat] = atmosphere(...)
mat = [t, p,rho,a]
Was informed about bad returns for density and that the code referenced a 1958 standard atmosphere. The density has been fixed and all altitude and lapse rates have been updated to the 1976 version.
Found some big bugs in it that made the function not work. Everything is all better now ^_^