MATLAB Answers

area of a circle function file / prompt and fprintf() output

32 ビュー (過去 30 日間)
Ashley Sullivan
Ashley Sullivan 2020 年 3 月 11 日
コメント済み: Rena Berman 2020 年 5 月 14 日
I have created a function file for the area of a circle, but I also need to include a prompt asking for the units of the radius. I also need to have the output area be expressed in the proper units, but am unsure of how to do either. This is what I have --
function [area] = area_circle(radius)
area = pi.*radius.^2;
  1 件のコメント
Rena Berman
Rena Berman 2020 年 5 月 14 日
(Answers Dev) Restored edit



Bhaskar R
Bhaskar R 2020 年 3 月 11 日
function area_circle()
radius = input('Enter the radius: ');
area_cir = pi.*radius.^2;
disp(['Area of circle: ', num2str(area_cir)])

その他の回答 (0 件)


Community Treasure Hunt

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

Start Hunting!

Translated by