Advertisement

Matlab code for diagonal exchange

clc;

m=input(' number of row= ');
n=input (' number of column =');

x=randi ([0,10],m,n)
r=m/2;
for i=1:1:r
 
    for j=1:1:r
        virtual=x(i+r,j+r);
        x(i+r,j+r)=x(i,j);
        virtual2=x(i+r,j);
        x(i+r,j)=x(i,j+r);
        x(i,j+r)= virtual2;
     
    end
    x(i,j)=virtual
end

No comments:

Post a Comment

Please comment bellow. Share your knowledge