I want to display result in different names.

1 次查看(过去 30 天)
function[result] = Geometric_cal(var1,var2,indicator)
% indicator = 1 is for Area of a Rectangle
% indicator = 2 is for Volume of a Cylinder
%indicator = 3 is for volume of a 4-sided Pyramid with equal sides
%indicator = 5 is for Volume of a Cone.
if indicator == 1
result = var1 * var2;
elseif indicator == 2
result = var1 * pi * var262;
elseif indicator == 3
result = (var1^2 * var2)/3;
elseif indicator == 4
result = pi * var2^2 * (var1/3);
else
result = ' Test your indicator';
end
how do I display those reults above in different names. as an example if my indicator is 1 I want to display my result as "Area of a rectangle" not like result.

回答(1 个)

KSSV
KSSV 2021-8-2
Read about fprintf.
function[result] = Geometric_cal(var1,var2,indicator)
% indicator = 1 is for Area of a Rectangle
% indicator = 2 is for Volume of a Cylinder
%indicator = 3 is for volume of a 4-sided Pyramid with equal sides
%indicator = 5 is for Volume of a Cone.
if indicator == 1
result = var1 * var2;
fprintf('Area of a Rectange = %f\n',result) ;
elseif indicator == 2
result = var1 * pi * var262;
fprintf('Volume of a Cylinder = %f\n',result) ;
elseif indicator == 3
result = (var1^2 * var2)/3;
fprintf('volume of a 4-sided Pyramid with equal sides = %f\n',result) ;
elseif indicator == 4
result = pi * var2^2 * (var1/3);
fprintf('Volume of a Cone = %f\n',result) ;
else
result = ' Test your indicator';
end

类别

Help CenterFile Exchange 中查找有关 3-D Volumetric Image Processing 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by