# How To Sort Row Matrix Element in Increasing Order in MATLAB

In previous post on matlab tutorial, we have discussed about How to find maximum value element of Matrix in MATLAB.

Now in

**Post-22 of Module-01**, we will discuss about how to sort row matrix element in matlab. In**figure-1,**A matlab program is shown with brief introduction about each line.
Figure.1 - MATLAB Program to sort row matrix element.

First of all, a message

**'Enter any Row Matrix: '**is displayed on the command window by the command of**line-3**. This command also store loaded matrix into variable**'A'**. Now this matrix with a message has been displayed on the command window by command written in**line-4 & line-5**. Number of rows and columns in matrix A is calculated is by the command written in**line-6**. A variable**'As'**is initialized with natural number from 1 to c (where c is number of column) by command written in**line-7**. Variable**'As'**will be used to store sorted row matrix. This initialized matrix will be displayed by the command written in**line-8 & line-9**with a message. A**'for loop'**is run from 1 to c by the command of**line-10**. Now we are selecting*minimum element*of the matrix A by the command of the**line-11**. This command give two values, in which one is*minimum value*stored in variable**'Amv'**and second is*index of minimum value*stored in variable**'Ai'**. This minimum value element of the matrix A is deleted with command of**line-12**. Now the minimum value stored in variable**Amv**is copied in**k (k=1)**position of variable**As**by the command of**line-13**. This**'for loop'**is repeated upto c (Number of column). After completion of 'for loop', a message with a matrix**As**is displayed on the command window by the command of**line-15 & line-16**. The command window output of this matlab program is shown in figure-2.
Figure.2 - Command Window output to sort row matrix element.

This matlab program has been executed on command window by typing its name

**'mod0122'**. After which a message**'Enter any Row Matrix: '**is displayed on the command window. When you type any matrix then three message with three matrix is displayed on the command window. First one is a matrix which is loaded into matlab. Second one is a initialized matrix with natural number to store sorted matrix. Third one is a sorted matrix in increasing order.**Video Tutorial :**How To Sort Row Matrix Element in Decreasing Order in MATLAB.

Brought to you By INFO4EEE (Website, Channel, and Classes).

[…] Read Post-21 of Module-I: How To Sort Row Matrix Element in Increasing Order in MATLAB […]

ReplyDelete[…] How to sort row matrix element in increasing order in MATLAB? In this matlab tutorial, we create a program to sort row matrix. […]

ReplyDelete[…] How To Sort Row Matrix Element in Increasing Order in MATLAB […]

ReplyDelete