{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

4_Quarterman_Patrick_HW06A - ╩lculates'n i.e the legnth of...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Patrick Quarterman Section 4 HW 6A Script: %Script 'Air_Density.ma %Patrick Quarterman, Section 4 %determines best fit coefficients for a linear model for air density %define vectors h and D h=10:3:25; %h is hight above sea level in km D=linspace(.8,.05,6); %Standard Air Density in kg/m^3 %calculate sums for least squares solution formula a=sum(h); %calculates sum of the elements in h b=sum(D); %Calculates sum of the elements in D c=sum(h.^2); %Calculates the sum of each element in h ^2 d=sum(h.*D); %Calculates sum of corresponding elements in h and D multiplied
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the 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

{[ snackBarMessage ]}