Writing a "circle" function
显示 更早的评论
The assignment: "write a circle that takes a scalar input r. It needs to return an output called area that is the area of a circle with radius r and a second output, cf that is the circumference of the circle. Use built-in function pi.
My answer:
function[area,cf] = circle(r)
% AREA and CIRCUMFERENCE of a circle, where r = radius of the circle.
r = rand;
cf = 2*pi*r;
area = pi*r.^2;
The "graders" response: "NOTE: the grader will only determine if your
solution for Problem 1 is correct or not. No score will be given.
Problem 1 (circle):
Testing with argument(s) 1
Feedback: Your function made an error for argument(s) 1
Your solution is _not_ correct."
I assumed r = rand was incorrect, however, now I think it means line(1).
Can anyone point me in the right direction?
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!