Write a function “cylcalcs” that will receive the radius and height of a cylinder and will return the area and volume of the cylinder. If the function is called as an expression or in an assignment statement with one variable on the left,
belongs to book: MATLAB: A Practical Introduction to Programming and Problem Solving|Stormy Attaway|Fourth Edition| Chapter number:10| Question number:7.10
All Answers
total answers (1)
cylcalcs.m
function [varargout] = cylcalcs(r,h)
a = area(r);
v = a*h;
if nargout <= 1
varargout{1} = [a v];
else
varargout{1} = a;
varargout{2} = v;
end
end
function a = area(r)
a = pi * r ^ 2;
end
need an explanation for this answer? contact us directly to get an explanation for this answer