Click here to Skip to main content
15,891,749 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Required
Write a function matmean that will receive a matrix as an input argument, and will calculate and return the overall average of all numbers in the matrix.
• Use nested loops, not built-in functions, to calculate the average.
Sample Output
>> A = [1 2 3; 4 5 6]
A =
1 2 3
4 5 6

>> matmean(A)
ans =
3.5000

>> matmean([-1 3;0 5])
ans =
1.7500

>> matmean([1 2 3 2 1])
ans =
1.8000

>> matmean(5)
ans =
5

-----------------------------

MSIL
Required
Write a program tempchart to display a temperature conversion chart.  The main script will:
•   Call a function that explains what the program will do.
•   Call a function to prompt the user for the minimum and maximum temperatures in degrees Fahrenheit and return both values.  This function checks to make sure that the minimum is less than the maximum.  If not, it calls a subfunction to swap the values.
•   Call a function to display temperatures in degrees F from the minimum to the maximum in one column, and the corresponding temperature in degrees Celsius in another column.  The conversion is C = (F - 32) * 5 / 9.
Sample Output
>> tempchart
This program displays a temperature conversion chart.
You need to enter a minimum and maximum temperature (in F).
The program will then display a table in both F and C.
Enter the minimum temperature value (degrees F): 32
Enter the maximum temperature value (degrees F): 40
   32.0 F        0.00 C
   33.0 F        0.56 C
   34.0 F        1.11 C
   35.0 F        1.67 C
   36.0 F        2.22 C
   37.0 F        2.78 C
   38.0 F        3.33 C
   39.0 F        3.89 C
   40.0 F        4.44 C
>> tempchart
This program displays a temperature conversion chart.
You need to enter a minimum and maximum temperature (in F).
The program will then display a table in both F and C.
Enter the minimum temperature value (degrees F): 32
Enter the maximum temperature value (degrees F): 25
   25.0 F       -3.89 C
   26.0 F       -3.33 C
   27.0 F       -2.78 C
   28.0 F       -2.22 C
   29.0 F       -1.67 C
   30.0 F       -1.11 C
   31.0 F       -0.56 C
   32.0 F        0.00 C
________________________________________
Posted

1 solution

dasman307 wrote:
Write a function matmean that will receive a matrix as an input argument, and will calculate and return the overall average of all numbers in the matrix.


OK, so get started.

Seriously if you do not know how to even start this task, or read the MATLAB documentation, or use the MATLAB website to search for sample code, then you are on the wrong study course.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900