Programme for circle parameters calculation

1 次查看(过去 30 天)
Progamme that takes radius of a circle as a parameter ie. (function arguments) and computes diameter, circumference and area.

回答(1 个)

Sarvesh Kale
Sarvesh Kale 2023-3-9
编辑:Sarvesh Kale 2023-3-9
please refer the following code
function [Area,circumference,diameter] = calculate(radius)
Area = pi*radius*radius;
circumference = 2*pi*radius ;
diameter = 2*radius ;
end
You need the define the function in a file and the name of the matlab file should be calculate.m, that is the same name as our function. then call the function as below
x = 5;
[A,c,d]=calculate(x);
fprintf("The Area of circle is %f\nCircumference is %f\nDiameter is %f",A,c,d);
I hope this helps your query
Thank you

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

产品


版本

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by