In: Mechanical Engineering
Given the matrix
a. Sort each column and store the result in an array B.
b. Sort each row and store the result in an array C.
c. Add each column and store the result in an array D.
d. Add each row and store the result in an array E.
We need to sort the given matrix column wise and row wise. This can be done by using the MATLAB command
sort(A, dim, type)
Where
A is the matrix to be sorted dim is used to sort either column wise (dim = 1, default) or row wise (dim = 2) type is used to select the sorting type as either ‘ascend’ or ‘descend’
(a)
Our matrix is
The MATLAB command is shown below:
(b)
Now, we need to sort row wise.
The MATLAB output is shown below:
(c)
Now, we need to add all the columns
The MATLAB output is
(d)
Now, we need to add each row
The MATLAB output is
A is the matrix to be sorted dim is used to sort either column wise (dim = 1, default) or row wise (dim = 2) type is used to select the sorting type as either ‘ascend’ or ‘descend’