How do I only display the 5 answers in the command window once?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
ARAH MIZORI
am 30 Aug. 2021
Beantwortet: Wan Ji
am 30 Aug. 2021
function [SA]=equTriPrismSurfArea(s,h)
SA = ((sqrt(3)./2) .* s.^2 + 3.*s.*h);
end
s = [1 2 3 4 5];
h = [1 2 3 4 5];
for i = 1:5
s1 = s(i);
h1 = h(i);
SA = equTriPrismSurfArea(s,h);
fprintf ("\nTotal surface area of equilateral triangular prism is %f\n",SA)
end
0 Kommentare
Akzeptierte Antwort
Wan Ji
am 30 Aug. 2021
s = [1 2 3 4 5];
h = [1 2 3 4 5];
SA = zeros(size(s));
for i = 1:5
s1 = s(i);
h1 = h(i);
SA(i) = equTriPrismSurfArea(s,h);
end
fprintf ("\nTotal surface areas of equilateral triangular prisms are %f\n",SA)
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Argument Definitions finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!