Tutorial Shift Sort
Tutorial Shift Sort
Example:
M = [1:5; 6:10; 11:15] %Creating 3x5 Matrix
To Perform Circular Left Shift use Negative Sign before the dimension. ( circshift( M, -K ))
Sorting Matrix
Sorting helps us in arranging data in either descending or ascending order, which helps
in better data interpretability. Matlab helps us in achieving it by using following functions.
Function: Sort Sorts elements of Matrix
Syntax: sort(matrix, dimension); % dimension: 1 Column , 2Row
Example:
X = [ 49,29,59,89; 19,79,99,39; 66,26,46,96] %Creating 3x4 matrix
Y = sort(X,1) %Sorting column in ascending order
Z = sort(Y,2) %Sorting row in ascending order
To Check if Data is sorted or not
Function: issorted Checks if the data is sorted
Syntax : issorted( X ); % Returns one if Sorted , else
returns zero
Example:
X = [ 99 65 32 11 80 33 ] %Creating an array
Table2.xls