Borrar filtros
Borrar filtros

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

6 visualizaciones (últimos 30 días)
Ashley Sullivan
Ashley Sullivan el 11 de Mzo. de 2020
Comentada: Rena Berman el 14 de Mayo de 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

Respuesta aceptada

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

Más respuestas (0)

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by