Available under Creative Commons-ShareAlike 4.0 International License.
% This script generates a table of conversions
% From Fahrenheit to Celsius temperatures
clc % Clear screen
disp('This script generates a table of conversions from Fahrenheit to Celsius')
disp(' ') % Display blank line
lowerF=input('Enter the beginning temperature in F: ');
upperF=input('Enter the ending temperature in F: ');
increment=input('Enter the increment value: ');
Fahrenheit=[lowerF:increment:upperF]; % Creating a row vector with F values
Celsius=5/9*(Fahrenheit-32); % Converting from F to C
disp(' ') % Display blank line
str = ['Fahrenheit Celsius ']; % Displaying table header
disp(str);
% Tabulating results in two columns, ' is being used to transpose row to column
disp([Fahrenheit' Celsius'])
The script output is as follows:
This script generates a table of conversions from Fahrenheit to Celsius Enter the beginning temperature in F: 20 Enter the ending temperature in F: 200 Enter the increment value: 20 Fahrenheit Celsius 20.0000 -6.6667 40.0000 4.4444 60.0000 15.5556 80.0000 26.6667 100.0000 37.7778 120.0000 48.8889 140.0000 60.0000 160.0000 71.1111 180.0000 82.2222 200.0000 93.3333
- 瀏覽次數:1817




