95,237 visitors in ONE day - Secret of Targeted Internet Traffic.avi

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

Data Orientation and Augmentation

Changing the data and put data is very commonly used in the program.. In the other programming language it may be quite difficult. But of course in MATLAB it becomes very easy.

-Changing the orientation of the data by the transpose
>> x = [1 3 5; 2 4 6]
x =

1     3     5
2     4     6

>> x = x'
x =

1     2
3     4
5     6

-Put data on the line.
>> x = [1 3 5;2 4 6]
x =

     1     3     5
     2     4     6

>> y = [7 7 7]
y =
    7     7     7

>> aug = [x;y]
aug =
     1     3     5
     2     4     6
     7     7     7

-Put data on the Column
>> x = [1 3 5; 2 4 6]
x =
     1     3     5
     2     4     6

>> y = [5;5]
y =
    5
    5

>> aug = [x y]
aug =
    1    3    5   5
    2    4    6   5