How to sort rows and columns in MATLAB ?

How to sort rows and columns in MATLAB ? 

Code : -

clc

clear all

close all

m = [ 1 2 3 ; 8 1 5 ; 4 6 4 ; 2 3 2 ]

b = sort( m ) % sort only as columns wise

% c = sort ( m , 'descend' ) % sort column in descending order

d = sort ( m , 2 ) % sort each row in ascending order

e = sort ( m , 2 , ( 'descend' ) ) % sort rows in descending order

 
Output : -



Sort according to rows : -
Code : -

clc

clear all

close all

m = [ 1 2 3 ; 8 1 5 ; 4 6 4 ; 2 3 2 ]

b = sortrows ( m )    % it will sort all rows according to their first digit

c = sortrows ( m , 2 )  % it will sort all row according to their 2nd digit

 

Output : -



******************************************

Keywords :-

Sort rows and columns in matlab

Sort rows in matlab

Sort columns in matlab

How to sort two columns in matlab

Sort columns in table matlab

ultrajobz , matlab ,

sort all columns in matlab ,

sort rows matlab command ,

sort each rows in matlab ,

sort rows in descending order matlab ,

sort rows descending matlab ,

sort rows alphabatically matlab ,

sort rows in matlab examples ,

sort in matlab ,

sort in matlab descending order ,

sort in matlab without sort function ,

sort structure in matlab ,

sort cell array in matlab ,

Post a Comment

0 Comments