Writing a "circle" function
Show older comments
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?
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!