MATLAB problem Would like a detailed answer line by line Ear

MATLAB problem. Would like a detailed answer line by line.

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 HW4Prob4. txt. 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.

Solution

Part a) Matlab code

p = @(h) 29.921*(1 - 6.8753*10^(-6)*h);% the pressure function
T = @(p) 49.161*log(p)+ 44.932; %the temperature function
fid = fopen(\'HW4Prob4.txt\',\'w\');
for h = -500:500:10000 % The height varies from -500 to 10000
   fprintf(fid,\'%d\\t%f\ \',h,T(p(h))); % Printing the values in the file
end

Result in HW4Prob4.txt

-500   212.177345
0          212.008636
500      211.839347
1000   211.669473
1500   211.499009
2000   211.327952
2500   211.156299
3000   210.984043
3500   210.811182
4000   210.637711
4500   210.463626
5000   210.288922
5500   210.113595
6000   209.937641
6500   209.761054
7000   209.583831
7500   209.405967
8000   209.227457
8500   209.048296
9000   208.868480
9500   208.688004
10000   208.506862

Part b)

load(\'HW4Prob4.txt\'); % loading the data in HW4Prob4.txt
format short g; % changing the display style format to short g
Hloaded = HW4Prob4(:,1); % copying the first column of HW4Prob4 to Hloaded
Tloaded = HW4Prob4(:,2); % Copying the second column of HW4Prob4 to Tloaded
{\'Altitude\',\'Boiling Temperature\';\'(ft)\',\'(degF)\'} % Dont put ; printing the heading
[Hloaded Tloaded] % Dont put ; Printing the result


OUTPUT in the command window

ans =

    \'Altitude\'    \'Boiling Temperature\'
    \'(ft)\'        \'(degF)\'           


ans =

         -500       212.18
            0       212.01
          500       211.84
         1000       211.67
         1500        211.5
         2000       211.33
         2500       211.16
         3000       210.98
         3500       210.81
         4000       210.64
         4500       210.46
         5000       210.29
         5500       210.11
         6000       209.94
         6500       209.76
         7000       209.58
         7500       209.41
         8000       209.23
         8500       209.05
         9000       208.87
         9500       208.69
        10000       208.51

>>

MATLAB problem. Would like a detailed answer line by line. Early explorers often estimated altitude by measuring the temperature of boiling water. Write a scrip
MATLAB problem. Would like a detailed answer line by line. Early explorers often estimated altitude by measuring the temperature of boiling water. Write a scrip

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site