
Try out this test problem first.
Given the variable x as your input, multiply it by two and put the result in y.
Examples:
Input x = 2 Output y is 4 Input x = 17 Output y is 34
返回输入值的二倍
function y = times2(x) % Do not edit this line. % Modify the line below so that the output y is twice the incoming value x y = 2*x; % After you modify the code, press the "Submit" button, and you're on your way.end % Do not edit this line.Given two input variables r and h, which stand for the radius and height of a cake, calculate the surface area of the cake you need to put frosting on (all around the sides and the top).
Return the result in output variable SA.
给定蛋糕的半径r和高度h,求需要进行糖霜处理的表面积。只包括顶部的底面积和周围的侧面积。底面积等于pi*r^2,侧面积等于2*pi*r*h。
function SA = func_frosting(r,h) SA = 2*pi*r*h+pi*r*r;endGiven an input vector F containing temperature values in Fahrenheit, return an output vector C that contains the values in Celsius using the formula:
将华氏度转化为摄氏度,并且公式已经给出:
C = (F–32) * 5/9
直接把公式复制进去就行。
function C = temp_convert(F) C=(F-32) * 5/9;endGiven two input vectors:
Return the name of the oldest person in the output variable old_name.
给定姓名数组和对应的年龄数组,返回年龄最大人的姓名。使用find函数和max函数对age进行操作然后索引name数组即可。
function old_name = find_max_age(name,age) old_name=name(find(age==max(age)));endIf a large number of fair N-sided dice are rolled, the average of the simulated rolls is likely to be close to the mean of 1,2,...N i.e. the expected value of one die. For example, the expected value of a 6-sided die is 3.5.
Given N, simulate 1e8 N-sided dice rolls by creating a vector of 1e8 uniformly distributed random integers. Return the difference between the mean of this vector and the mean of integers from 1
免责声明:本文系网络转载或改编,未找到原创作者,版权归原作者所有。如涉及版权,请联系删