Data Sorting in MATLAB

Data sorting techniques are often used in data processing programs. MATLAB provides a special function that is 'sort' to do sorting. Using 'sort' can be in two ways. The first way is used to sort the data in the column, its syntax as follows:

var2 = sort(var1,1)

var1 is the matrix or vector to be sorted. Here's how to use it in the program:
>> a=[2 5 7; 7 5 1; 8 7 5]
a =

     2     5     7
     7     5     1
     8     7     5

>> b = sort(a,1)
b =

     2     5     1
     7     5     5
     8     7     7

The second way is used to sort the data on the direction of the line, its syntax as follows:
 >> a=[2 5 7; 7 5 1; 8 7 5]
a =

     2     5     7
     7     5     1
     8     7     5

>> b = sort(a,2)
b =

     2     5     7
     1     5     7
     5     7     8

1 comments:

Anonymous said...

The best casino site. Live Dealer games from Asia, Europe
The best casino site. Live Dealer games from Asia, Europe and New Zealand. All about Asia. luckyclub Live casino games from Asia, Europe and New Zealand.

Post a Comment