Create a function to sort the rows of a matrix by the third colum in descending
ID: 3909975 • Letter: C
Question
Create a function to sort the rows of a matrix by the third colum in descending order. You will be given a random 10x10 matrix called randMat by the test case. Store the result in a variable named sortedMat. The rows of the matrix should stay the same (have the same value in each column as before) after sorting. The only difference should be the row order of ??ch Your Function C Reset MATLAB Documentation 1 %function definition. Do not edit. 2 function sortedMat = sortMatrixRows(randMat) sort rows of matrix by third row in descending order. 5 endExplanation / Answer
The code for question is given using built-in sortrows() function. Please do rate the answer if it helped. Thank you
function sortedMat = sortMatrixRows(randMat)
%sort rows of matrix by third column in descending order
sortedMat = sortrows(randMat, 3, 'descend');
end
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.