Originally Posted by

**deragon999** I want it like this:

function [surface_area area volume]=cylinder(height,radius)

So that the following can be typed into matlab command:

cylinder([height1, height2, height3...],[radius1, radius2, radius3...])

which will result in an output of:

surfacearea1 area1 volume1

surfacearea2 area2 volume2

surfacearea3 area3 volume3

etc etc etc

If the output matrix has to be aligned a different way(my examples rows as columns instead) then thats fine, i just need to be able to get an output that gives all 3 areas/volumes from the given dimensions.

Thanks for taking some time to look at this though.

Code:

function rv=cylinder(height, radius)
% first make sure we have column vectors
sz1=size(height);
if sz1(1) ~= 1
ht=height';
else
ht=height;
end
sz1=size(radius);
if sz1(1) ~= 1
rd=radius';
else
rd=radius;
end
sarea=ht.*(2*rd*pi);
xarea=pi*rd.^2;
volume=ht.*xarea;
rv=[sarea;xarea;volume]';

CB