我需要两个问题的matlab帮助 [英] i need help with two Qustion for matlab
问题描述
必需
编写一个函数matmean,它将接收矩阵作为输入参数,并将计算并返回矩阵中所有数字的总平均值.
•使用嵌套循环而不是内置函数来计算平均值.
样本输出
>> 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
-----------------------------
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
-----------------------------
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
________________________________________
推荐答案
写一个函数matmean将收到一个矩阵作为输入参数,并将计算并返回矩阵中所有数字的总平均值.
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.
好的,开始吧.
严重的是,如果您甚至不知道如何开始该任务,或者不阅读MATLAB文档,或者使用MATLAB网站搜索示例代码,那么您就在错误的学习课程上.
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.
这篇关于我需要两个问题的matlab帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!