This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: %calculates 'n' i.e the legnth of the two vectors n=length(h); %legnth of vectors (h and D must be same legnth) %calculates slope coefficient a1=(n*d-a*b)/(n*c-a^2) %calculates y intercept for equation a0=mean(D)-a1*mean(h) %plot least squares equation h=0:3:30; y=a1*h+a0; plot(h,y) xlabel( 'height (km)' ) ylabel( 'Density (kg/m^3)' ) title( 'Best Fit for Air Density' ) MATlab Commands: >> run Air_Density a1 =-0.0500 a0 = 1.3000 5 10 15 20 25 30-0.2 0.2 0.4 0.6 0.8 1 1.2 1.4 height (km) Density (kg/m 3 ) Best Fit for Air Density...
View Full Document
This note was uploaded on 11/16/2010 for the course EGR 102 taught by Professor Hinds during the Spring '09 term at Michigan State University.
- Spring '09