Q:

Write a function to calculate the volume of a cone. The volume V is V = AH where A is the area of the circular base (A = r 2 where r is the radius) and H is the height. Use a nested function to calculate A

0

 Write a function to calculate the volume of a cone. The volume V is V = AH where A is the area of the circular base (A = π r 2 where r is the radius) and H is the height. Use a nested function to calculate A.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

nestConeVol.m

function outvol = nestConeVol(rad, ht)

% Calculates the volume of a cone

% uses a nested function to calculate the area of

% the circular base of the cone

% Format of call: nestConeVol(radius, height)

% Returns the volume of the cone

outvol = conebase * ht;

function outbase = conebase

% calculates the area of the base

% Format of call: conebase or conebase()

% Returns the area of the circular base

outbase = pi*rad^2;

end % inner function

end % outer function

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now