Write a function called circle that takes a scalar input x. It needs to return an output called area that is a area of a circle with radius x and a second output of that is the circumference of the same circle. You are allowed to use the built in fun
6 views (last 30 days)
Show older comments
Write a function called circle that takes a scalar input x. It needs to return an output called area that is a area of a circle with radius x and a second output of that is the circumference of the same circle. You are allowed to use the built in function pi. In fact you need to use it to get the value of pi accurately as possible.
0 Comments
Answers (2)
Image Analyst
on 14 Aug 2016
1 Comment
Image Analyst
on 20 Aug 2016
From your comment to John, it doesn't appear that you read or took the advice in the link I gave you, so you can unaccept my Answer since it didn't help you, though it could have.
I have fixed your formatting so people can read it.
John BG
on 14 Aug 2016
Hi Prabhleen
let me call the function f_circle, to avoid conflict with for example the already existing function circle in the RF toolbox.
Your function:
function [Area,Perimeter,L]=f_circle(x)
% Area: pi*x^2 area of circle with radius x
% Perimeter: 2*pi*x perimeter length of circle with radius x
% x can be a vector
minargs=1;maxargs=1;narginchk(minargs,maxargs); % only 1 input accepted
if ~isequal('double',class(x)) 5 input has to be type double
disp('input type not double');
return;
end
Area=pi*x.^2;
Perimeter=2*pi*x;
end
Prabhleen
would you please be so kind to mark my answer as Accepted Answer?
To any other reader, please if you find this answer of any help solving your question,
please click on the thumbs-up vote link,
thanks in advance
John BG
6 Comments
James Tursa
on 9 Mar 2017
The question was obviously homework from the very beginning as we all know ...
See Also
Categories
Find more on Logical 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!