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
belongs to book: MATLAB: A Practical Introduction to Programming and Problem Solving|Stormy Attaway|Fourth Edition| Chapter number:10| Question number:13.10
All Answers
total answers (1)
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