Help writing script for problem.
显示 更早的评论
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 个评论
Fangjun Jiang
2011-9-9
please format your code as {}code and tell WHERE are you stuck.
Walter Diolosa
2011-9-9
Walter Roberson
2011-9-10
What you have,
C = (F - 32) .* 5/9
is fine for converting farhenheit to celcius.
Walter Diolosa
2011-9-10
回答(2 个)
Walter Roberson
2011-9-9
0 个投票
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.
类别
在 帮助中心 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!