Info

この質問は閉じられています。 編集または回答するには再度開いてください。

How do I only result in 5 answers (I want the matrix to times 1 by 1 and 2 by 2 and 3 by 3 etc. not 1 by 1 and 1 by 2 and 1 by 3 etc.)

1 ビュー (過去 30 日間)
ARAH MIZORI
ARAH MIZORI 2021 年 8 月 30 日
終了済み: John D'Errico 2021 年 8 月 30 日
s = 1;
s1 = input('Enter the number of columns : ');
h = 1;
h1 = input('Enter the number of columns : ');
for p = 1:s
for c=1:s1
fprintf('Enter the value in row %d column %d\n',p,c);
M(p,c)=input('');
end
end
disp(M)
for i = 1:h
for j = 1:h1
fprintf('Enter the value in row %d column %d\n',i,j);
M1(i,j)=input('');
end
end
disp(M1)
for i = 1:5
for j = 1:5
s1 = M(i);
h1 = M1(j);
SA = ((sqrt(3)./2) * s1^2 + 3*s1*h1);
fprintf ("\nTotal surface area of equilateral triangular prism is %f\n",SA)
end
end

回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by