Problem 2413. Temperature Conversion Utility

There are a few problems on Cody regarding temperature conversion (C to K, C to F, F to C), but none include Rankine. Furthermore, they each involve simple one-liner solutions. For this problem, you are to write a utility function that takes a given temperature and two capital letters designating which temperature scale is being converted to which. For example, T_convertor(100,'C','F') requires 100 degrees Celsius be converted to Fahrenheit.

The test suite includes all 16 possible combinations: C to F, C to R, C to C, C to K, K to F, K to R, etc. (Yes, the redundant combinations are included.)

For reference, temperature conversion formulas are available at

A follow-on problem (more difficult with string inputs) is located here:

Solution Stats

66.67% Correct | 33.33% Incorrect
Last solution submitted on Feb 16, 2017
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!