Help writing script for problem.
Show older comments
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 Comments
Fangjun Jiang
on 9 Sep 2011
please format your code as {}code and tell WHERE are you stuck.
Walter Diolosa
on 9 Sep 2011
Walter Roberson
on 10 Sep 2011
What you have,
C = (F - 32) .* 5/9
is fine for converting farhenheit to celcius.
Walter Diolosa
on 10 Sep 2011
Answers (2)
Walter Roberson
on 9 Sep 2011
0 votes
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 Comment
Walter Diolosa
on 10 Sep 2011
Walter Diolosa
on 11 Sep 2011
0 votes
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!