Info

This question is closed. Reopen it to edit or answer.

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 view (last 30 days)
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

Answers (0)

This question is closed.

Community Treasure Hunt

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

Start Hunting!