Question

All in MATLAB

mixing_ratio function:

function w = mixing_ratio(P,T) %function mixing_ratio has 2 inputs P in millibars and T in K

Po = 1013.246;

To = 373.16;

a1 = 11.344*(1-T/To);

a2 = -3.49149*(To/T - 1);

b1 = -7.90298*(To/T - 1);

b2 = 5.02808*log10(To/T);

b3 = -1.3816*(10^a1 -1)/(10^7);

b4 = 8.1328*(10^a2 -1)/(10^3);

b5 = log10(Po);

b = b1 + b2 + b3 + b4 + b5;

Pv = 10^b;

w = 0.62197*Pv/(P - Pv);

end

Appendix C Wetbulb Temperature As explained by Dr. Colby, wetbulb temperature is the temperature a parcel of air can be cooled to by evaporating water into it at constant pressure. Given the air temperature Ta (K), the dew point Ta (K), and the atmospheric pressure pa (hectopascals), the wetbulb temperature can be calculated by finding the root of the function Aq given by where cp = 1005 J/(kg K) is the heat capacity of water vapor; L = 2.501 × 106 J/kg is the latent heat of water vapor at 0°C; w denotes the mixing ratio corresponding to temperature Td and pressure pa, and w2 denotes the mixing ratio corresponding to temperature T and pressure pa. Use your function mixing.ratio to calculate wi and w. The units of T are degrees K.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

%mixing_ratio.m

function w = mixing_ratio(P,T) %function mixing_ratio has 2 inputs P in millibars and T in K
Po = 1013.246;
To = 373.16;
a1 = 11.344*(1-T/To);
a2 = -3.49149*(To/T - 1);
b1 = -7.90298*(To/T - 1);
b2 = 5.02808*log10(To/T);
b3 = -1.3816*(10^a1 -1)/(10^7);
b4 = 8.1328*(10^a2 -1)/(10^3);
b5 = log10(Po);
b = b1 + b2 + b3 + b4 + b5;

Pv = 10^b;
w = 0.62197*Pv/(P - Pv);
end

%wetBulb.m

%Prompt the user for Temperature
Ta = input('Enter air temperature in degK: ');
Td = input('Enter dew temperature in degK: ');

%Prompt user for atmospheric pressure
pa = input('Enter atmospheric pressure in hPa: ');

%Call for function mixing_ratio to calculate w1 and w2
w1 = mixing_ratio(pa, Td);
w2 = mixing_ratio(pa, Ta);

%Calculate the wetbulb temperature
cp = 1005;
L = 2.501*10^6;
delQ = (L/(1+w2))-(cp*(Ta - Td))*(1+0.8*w2);

%Print the results
fprintf("w1 = %f\nw2 = %f\nWetbulb temperature = %f\n", w1, w2, delQ);

Screenshot of Code Screen:

MATLAB R2017a HOME PLOTS EDITOR lSearch Documentation Log In Find Files 凶Compare ▼ 연 96.aste 9e骗 Go To▼ Comment 1 New Open Save Breakpoints Run Run and Advance Advance Run and Print ▼ Find Indent Time FILE C. Program Filesト MATLAB R2017aトbin Editor-CAProgram Files MATLAB\R2017albin wetBulb.m 田 mixing ratio.mwetBulb.m x Prompt the user or Temperature 2-Ta - input (Enter air temperature in degK:: 3- Td = Input ( Enter dew temperature 1n degK: ); Prompt uaer for atmospheric preaaure pa - input(Enter atmospheric pressure in hPa: Call for function mixing_ratio to calculate wl and w2 10w2mixing ratio (pa, Ta) 12 13-p1005 14-L-2.50110: Calculate the wetbulb temperature 16 17 18 19 Print the reaults fprintf (w f nw2nWetbulb temperaturen, wl, w2, delQ): script Ln 10 Col 27 06:10 O Type here to search ^慘后 ENG 28-11-2018

Screenshot of Output:

Add a comment
Know the answer?
Add Answer to:
All in MATLAB mixing_ratio function: function w = mixing_ratio(P,T) %function mixing_ratio has 2 inputs P in...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT