Filter löschen
Filter löschen

Programme for circle parameters calculation

3 Ansichten (letzte 30 Tage)
Francis Adams Kwofie
Francis Adams Kwofie am 9 Mär. 2023
Kommentiert: Sarvesh Kale am 9 Mär. 2023
Progamme that takes radius of a circle as a parameter ie. (function arguments) and computes diameter, circumference and area.

Antworten (1)

Sarvesh Kale
Sarvesh Kale am 9 Mär. 2023
Bearbeitet: Sarvesh Kale am 9 Mär. 2023
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
  2 Kommentare
Francis Adams Kwofie
Francis Adams Kwofie am 9 Mär. 2023
Undefined function or variable 'r'.
Error in calculate (line 3)
circumference = 2*pi*r;
Sarvesh Kale
Sarvesh Kale am 9 Mär. 2023
edited the code, try again

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Produkte


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by