Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

USE MATLAB TO ANSWER: Write a function file called mixing_ratio.m that calculate

ID: 3714545 • Letter: U

Question

USE MATLAB TO ANSWER:

Write a function file called mixing_ratio.m that calculates the mixing ratio for air as described in Appendix B.

• There should be 2 inputs to mixing_ratio.m: temperature T and pressure p.

• There should be 1 output from mixing_ratio.m: the value of the mixing ratio w for the given values of T and p.

• Be sure to include comments describing the function and its inputs and output.

Appendix B - Mixing Ratio The mixing ratio w is the ratio of the mass of water vapor to the mass of dry air. The mixing ratio corresponding to air temperature T and air pressure p is calculated as follows 0.62197 p, p Po where p, denotes vapor pressure. The vapor pressure is calculated in terms of air temperature T as follows: P10 where po -1013.246 ?? 373.16 ! = 11.344 (1-T/T) a2 ?3.49149 (Tp/T-1) b17.90298 (To/T - 1) b2 - 5.02808 log10 (To/T) bg = -1.3816 (10°1-1) /107 ba = 8.1328 (10a2-1) /103 bslog1o(po) and

Explanation / Answer

function [w]=mixing_ratio(T,p)
%[w]=mixing_ratio(T,p)
%a function that calculates the mixing ratio for air
%inputs:temperature T and pressure p.
%output: the value of the mixing ratio w for the given values of T and p.


p0=1013.246;
T0=373.16;
a1=11.344*(1-T/T0);
a2=-3.49149*(T0/T-1);
b1=-7.90298*(T0/T-1);
b2=5.02808*log10(T0/T);
b3=-1.3816*(10^a1-1)/10^7;
b4=8.1328*(10^a2-1)/10^3;
b5=log10(p0);
b=b1+b2+b3+b4+b5;
pv=10^b;
w=.62197*pv/(p-pv);