a) Early explorers often estimated altitude by measuring the temperature of boil
ID: 3860610 • Letter: A
Question
a) Early explorers often estimated altitude by measuring the temperature of boiling water. Write a script file that uses the following two equations to make a table that modern-day hikers could use for the same purpose. p = 29.921(1 - 6.8753 times 10^-6 h), T_b = 49.161 ln p + 44.932 where p is atmospheric pressure in inches of mercury, T_b is the boiling temperature in degree F, and h is the altitude in feet. The table should have two columns: the first is the altitude and the second is the boiling temperature. The altitude should go from -500 ft. to 10,000 ft. in increments of 500 ft. Save the table results in an ASCII file called. b) Write another script file that does the following: Load the data saved in HW4Prob4.txt: Using the variable that contains the loaded data, assign the first column to a variable called Hloaded and the second column to a variable called Tloaded: Display these two variables in the Command Window without using the disp and fprintf functions.Explanation / Answer
Answer a)
h = -500:500:10000 ;
p = 29.921 * (1 - 6.8753 * 10^-6 .*h);
temp = 49.161 .* log(p) + 44.932;
table = [h' temp'];
fid = fopen('HW4Prob4.txt','w');
fprintf(fid,"%f,%f ", table');
fclose(fid);
Answer b)
fid = fopen('HW4Prob4.txt','r');
sizeT = [2 inf]; %set size to 2 rows inf columns
loadedT = fscanf(fid, "%f,%f",sizeT);
loadedT = loadedT'; %transpose it so that tehre are 2 columns
HLoaded = loadedT(:,1);
TLoaded = loadedT(:,2);
format shortg
[HLoaded TLoaded]
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.