4 Converting a temperature to different units

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

\[T_f = \frac{9}{5} T_c + 32\]

where \(T_c\) is a temperature in degrees Celcius and \(T_f\) is the temperature in degrees Fahrenheit.

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

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

4.1 Using cel2fahr.m

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

degC = 25;
degF = cel2fahr(degC)

A correct function would cause the value 77 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 cel2fahr.m

Consider the following three temperatures in degrees Celcius:

  • \(T_1 = 0^\circ\)C (freezing point of water at 1 atmosphere of pressure)
  • \(T_2 = 100^\circ\)C (boiling point of water at 1 atmosphere of pressure)
  • \(T_3 = 5505^\circ\)C (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 cel2fahr that you created earlier. Your script should store the three temperatures in variables named F1, F2, and F3.