I have a homework question I need assistance with. It has to do with surface area and parameters.

8 views (last 30 days)
I am attempting to answer a homework problem that I have. The question asks, the surface area of a sphere is given by A = 4(pi)r^2. I am supposed to write a function that takes the radius as a parameter and returns the surface area of the sphere. The function is also supposed to work if a vector of a radius values are given. I have no clue where to start and a nudge in the right direction or an answer would be extremely helpful thanks!

Answers (1)

mohammad m
mohammad m on 14 Dec 2016
Edited: mohammad m on 14 Dec 2016
function A=Area(r)
A=4*pi*r.^2;
end
write your vector like this in command:
r=[r1 r2 r3 ...]
and in command by Area(r) calculate areas.

Community Treasure Hunt

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

Start Hunting!