MATLAB Answers

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

조회 수: 7(최근 30일)
Ashley Sullivan
Ashley Sullivan 11 Mar 2020
댓글: Rena Berman 14 May 2020 16:40
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 14 May 2020 16:40
(Answers Dev) Restored edit

로그인 to comment.

채택된 답변

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

  댓글 수: 0

로그인 to comment.

추가 답변(0개)

이 질문에 답변하려면 로그인을(를) 수행하십시오.


Translated by