Function sortrows - sorting strings, MATLAB in Statistics

function sortrows - sorting strings:

The function sortrows sorts each and every row as a block, or group, and it also will work on numbers. Here in this illustration the rows starting with 3 and 4 are placed first then, for the rows starting with 5, the values in the second column (6 and7) determine the order.

>> mat = [5 7 2; 4 6 7; 3 4 1; 5 6 2]

mat =

5 7 2

4 6 7

3 4 1

5 6 2

>> sortrows(mat)

ans =

3 4 1

4 6 7

5 6 2

5 7 2

Posted Date: 10/22/2012 7:48:04 AM | Location : United States






Your posts are moderated
Related Questions
Example of Median For the vector [1 4 5 9 12 33], the median is the average of the 5 & 9 in the middle: >> median([1 4 5 9 12 33]) ans =     7

Program of Persistent variables: The program below elaborates this. The script calls a function func1 that initializes a variable count to 0, then increment it, and print the

Curve Fitting: The data is fundamentally either discrete or continuous. In most of the applications, data is sampled, for illustration, The temperature recorded every ho

Illustration of Mode When there is more than one value with similar (highest) frequency, then the smaller value is mode. In the case below, as 3 and 8 appear twice in the vecto

Data structure layers: There are many layers in this variable. For illustration,  cyls is the whole data structure, that is a vector of structs  cyls(1) is a separate

Nested Structures: The nested structure is a structure in which at least one of the members is itself a structure. For illustration, a structure for the line segment may co

Function Stubs: The other common debugging method, which is used when there is a script main program which calls many functions, is to use the function stubs. A function stub

Polynomials: Simple curves are polynomials of various degrees, or orders. The degree is the integer of the highest exponent in the expression. The illustrations are as follows

Example of Functions which return values: Calling this function prints the circumference, since there is no way to store the value, hence, it can be used in following computat

Logical Built-In Functions: There are built-in functions in the MATLAB which are useful in conjunction with vectors or matrices of all logical true or false values; two of the