area of a circle function file / prompt and fprintf() output
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Ashley Sullivan
le 11 Mar 2020
Commenté : Rena Berman
le 14 Mai 2020
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
Réponse acceptée
Bhaskar R
le 11 Mar 2020
function area_circle()
radius = input('Enter the radius: ');
area_cir = pi.*radius.^2;
disp(['Area of circle: ', num2str(area_cir)])
end
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Environment and Settings dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!