4 Converting a temperature to different units

Two commonly used scales for measuring temperature are Fahrenheit and Kelvin. Recall that Fahrenheit and Kelvin are related by the following equation:

\[T_f = \frac{9}{5} T_k - 459.67\]

where \(T_k\) is a temperature in degrees Kelvin and \(T_f\) is the temperature in degrees Fahrenheit.

In MATLAB, open the file kel2fahr.m. This file contains a user-defined function that when completed has one input that is a temperature in degrees Kelvin and returns the equivalent temperature in degrees Fahrenheit.

Complete the function so that it returns the correct temperature in degrees Fahrenheit.

4.1 Using kel2fahr.m

\(300\) degrees Kelvin is the temperature of a warm summer day in southern Ontario. Test your function by typing the following in the MATLAB Command Window:

degK = 300;
degF = kel2fahr(degK)

A correct function would cause the value 80.33 to be output. If the correct value is not output, review your function and correct any errors that you find.

4.2 Solve a simple problem using kel2fahr.m

Consider the following three temperatures in degrees Kelvin:

  • \(T_1 = 0\) K (absolute zero)
  • \(T_2 = 273.15\) K (freezing point of water at 1 atmosphere of pressure)
  • \(T_3 = 5778\) K (approximate surface temperature of the sun)

In MATLAB, open the script file convertTemp.m. Edit the script so that it converts the three temperatures above to degrees Fahrenheit. Your script should use the function kel2fahr that you created earlier. Your script should store the three temperatures in variables named F1, F2, and F3.