Matlab Help : Write a function that converts temperatures in Celsius to temperat
ID: 3930061 • Letter: M
Question
Matlab Help :
Write a function that converts temperatures in Celsius to temperatures in Fahrenheit. The function should get two temperatures as input, a lower temperature (Tlow) and a upper temperature (Tupp). The function should convert all of the temperatures between Tlow and Tupp to Fahrenheit. The output of the function should be a two column matrix with the first column showing the temperature in Celsius, from Tlow and Tupp, and the second column showing the corresponding temperature in Fahrenheit.
Explanation / Answer
% This function is named 'temperature.m'.
% It has one input value 'x' and two outputs, 'c' and 'f'.
% If 'x' is a Celsius number, output variable 'f'
% contains its equivalent in Fahrenheit degrees.
% If 'x' is a Fahrenheit number, output variable 'c'
% contains its equivalent in Celsius degrees.
% Both results are given at once in the output vector [c f]
function [c f] = temperature(x)
f = 9*x/5 + 32;
c = (x - 32) * 5/9;