Question: MATLAB homework. We have to use row sort. We can NOT use any loops including while loop. Please help as I cant figure it out
MATLAB homework. We have to use row sort. We can NOT use any loops including while loop. Please help as I cant figure it out
Row sort Write a function Custom Sort that takes a 2D array inMat with random integers between (inclusively) -100 and 100, and produces a n by m array outMat that consists of sorted values in inMat such that the lowest value in inMat is the (1,1) position in outMat, and order the remaining elements left to right on the first row till last column, starting with the next row and so on. Hint: Use the internal sort and reshape Restriction: You may not use loops. For example 8 19 17 12 16 11 16 23]; 8 11 12 16 2 19 [outMat] CustomSort ( inMat ) produces 2 3 12 12 16 16 16 17 19 19 Your Function Save 1 function [outMat] = CustomSort ( inMat ) 2% Takes a 2D array inMat with random integers between (inclusively) -100 and 100, 3% and produces a n by m array outMat that consists of sorts values 4% in inMat such that the lowest value in inMat is the (1,1) position 5% in outMat, and order the remaining elements left to right on 6% the first row till last column, starting with the next row and so on 7 Your code goes here % 9 10 end Code to call your function Reset 1inMat-randi (10,4,4)-5; 2 [outMat] CustomSort ( inMat)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
