许可优化
许可优化
产品
产品
解决方案
解决方案
服务支持
服务支持
关于
关于
软件库
当前位置:服务支持 >  软件文章 >  CODY Contest 2020 MATLAB Onramp Practice:全部15题解析

CODY Contest 2020 MATLAB Onramp Practice:全部15题解析

阅读数 5
点赞 0
article_banner

第一题 Problem 1. Times 2 - START HERE

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.

第二题 Problem 44943. Calculate Amount of Cake Frosting

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;end

第三题 Problem 44944. Convert from Fahrenheit to Celsius

Given 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;end

第四题 Problem 44947. Find the Oldest Person in a Room

Given two input vectors:

  • name - user last names
  • age - corresponding age of the person

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)));end

第五题 Problem 44951. Verify Law of Large Numbers

If 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
免责声明:本文系网络转载或改编,未找到原创作者,版权归原作者所有。如涉及版权,请联系删


相关文章
技术文档
QR Code
微信扫一扫,欢迎咨询~
customer

online

联系我们
武汉格发信息技术有限公司
湖北省武汉市经开区科技园西路6号103孵化器
电话:155-2731-8020 座机:027-59821821
邮件:tanzw@gofarlic.com
Copyright © 2023 Gofarsoft Co.,Ltd. 保留所有权利
遇到许可问题?该如何解决!?
评估许可证实际采购量? 
不清楚软件许可证使用数据? 
收到软件厂商律师函!?  
想要少购买点许可证,节省费用? 
收到软件厂商侵权通告!?  
有正版license,但许可证不够用,需要新购? 
联系方式 board-phone 155-2731-8020
close1
预留信息,一起解决您的问题
* 姓名:
* 手机:

* 公司名称:

姓名不为空

姓名不为空

姓名不为空
手机不正确

手机不正确

手机不正确
公司不为空

公司不为空

公司不为空