I want to display result in different names.

1 vue (au cours des 30 derniers jours)
Sandun Munasinghekankanamge
Sandun Munasinghekankanamge le 2 Août 2021
Commenté : Rena Berman le 23 Sep 2021
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 commentaire
Rena Berman
Rena Berman le 23 Sep 2021
(Answers Dev) Restored edit

Connectez-vous pour commenter.

Réponses (1)

KSSV
KSSV le 2 Août 2021
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

Catégories

En savoir plus sur 3-D Volumetric Image Processing dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by