【发布时间】:2016-02-19 11:03:51
【问题描述】:
function [ surface_area, volume ] = cube_and_sphere_calculator( geometry,l_r )
if geometry == 1
surface_area = 6 * l_r^2
volume = l_r^3
elseif geometry == 0
surface_area = 4*pi*l_r^3
volume = (4/3)*pi*l_r^3
else
disp('you have to choose a value that is either equal to one if you want to calculate the surface area and the volume of a cube or equal to zero if you want to calculate the surface area and the volume of a sphere')
end
end
如果我在公式后面加上分号,matlab 只给出一个输出变量:ans。这个答案等于表面积。我想要两个输出变量,我希望它们是surface_area 和volume。为什么它不起作用?
【问题讨论】: