area of a circle function file / prompt and fprintf() output
11 次查看(过去 30 天)
显示 更早的评论
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;
end
采纳的回答
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)])
end
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Environment and Settings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!