Question: function [ outMat ] = CustomSort ( inMat ) % Takes a 2 D array inMat with random integers between ( inclusively ) - 1

function [outMat]= CustomSort ( inMat )
% Takes a 2D array inMat with random integers between (inclusively)-100 and 100,
and produces an m by n array outMat that consists of sorts 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.
% Your code goes here %
sortedArray= sort inMat (:);
reshapedArray= reshape sortedArray, inMat, 2), inMat, 1));
outMat =( reshapedArray )'
end
Code to call your function ?
[[1, inMat=randi (10,4),4)-5;],[2, inMat =[1,2,3;4,5,6;7,8,9]],[3,[outMat]= CustomSort (inMat)]
Output
 function [outMat]= CustomSort ( inMat ) % Takes a 2D array

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!