Help writing script for problem.
Ältere Kommentare anzeigen
Problem: Ask user to enter a temperature matrix that has 3 rows and 5 columns. Columns represent average temperature in Fahrenheit from 2006 to 2010 and rows represent months from January to March as shown in the following matrix
January
February
March
2006
2007
2008
2009
2010
Once they enter all the information, convert all the temperatures in Celsius and display them as shown below
Actual Program Output
Enter the values of average temperatures in Fahrenheit from 2006 to 2010 for the months of January to March in a 5x3 matrix. Rows represent month while columns represent year
[12 34 45 67 12;54 36 45 98 76;12 43 54 78 98]
Average values of temperatures in Celsius are as follows
January
-------
2006 2007 2008 2009 2010
-11 1 7 19 -11
February
-------
2006 2007 2008 2009 2010
12 2 7 37 24
March
-------
2006 2007 2008 2009 2010
-11 6 12 26 37
I am stuck!
Please help!
I think I am on the right path but I don't know were to go from here. I am a bit confused!
% Program will convert Fahrenheit Temperatures to Celsius from 2006 to 2010
% for the months of January to March.
% User will enter a temperature matrix that has 3 rows and 5 colums.
% Columns will represent the average temperature.
fprintf('Enter the values of average temperatures in Fahrenheit from 2006 to 2010 for the months of\n')
fprintf('January to March in a 5x3 matrix. Rows represent month while columns represent year\n')
fprintf('\n[12 34 45 67 12;54 36 45 98 76;12;43;54;78;98]\n')
fprintf('\nAverage Values of temperatures in Celsius are as follows\n')
fprintf('\nJanuary\n')
fprintf('\n-------\n')
fprintf('\n2006 2007 2008 2009 2010\n')
input = F
C = (F - 32) .* 5/9
4 Kommentare
Fangjun Jiang
am 9 Sep. 2011
please format your code as {}code and tell WHERE are you stuck.
Walter Diolosa
am 9 Sep. 2011
Walter Roberson
am 10 Sep. 2011
What you have,
C = (F - 32) .* 5/9
is fine for converting farhenheit to celcius.
Walter Diolosa
am 10 Sep. 2011
Antworten (2)
Walter Roberson
am 9 Sep. 2011
0 Stimmen
Please do not use a variable named "input", as that conflicts with the important MATLAB routine named "input"... a routine that, in fact, you should be considering invoking right there.
1 Kommentar
Walter Diolosa
am 10 Sep. 2011
Walter Diolosa
am 11 Sep. 2011
0 Stimmen
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!