You are on page 1of 1

EXPERIMENT:1(A) DATE :09/08/2019

% write a .m file to perform transpose of matrix


% 1 2 7
% 5 6 3
% 7 5 8

%START
s=[1 2 7;5 6 3;7 5 8];
for i=1:3
for j=i:3
a=s(i,j);
s(i,j)=s(j,i);
s(j,i)=a;
end
end
disp(s)
%END

Command Window

Output:
1 5 7
2 6 5
7 3 8

You might also like