Given two N-dimensional matrices A and B, first sort A in increasing order and then sort B with respect to the index of A.
You produce sorted B as output. Normally the sort command does not work as the dimension increases. You must find a way to apply the sort command to an N-dimensional matrix.
Example
A(:,:,1) =
33 29
26 28A(:,:,2) =
13 35
22 3B(:,:,1) =
31 55
26 38B(:,:,2) =
59 51
36 29Bsorted(:,:,1) =
26 38
31 55Bsorted(:,:,2) =
59 29
36 51
Solution Stats
Problem Comments
3 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers18
Suggested Problems
-
Increment a number, given its digits
688 Solvers
-
Who knows the last digit of pi?
692 Solvers
-
11133 Solvers
-
Return the first and last characters of a character array
12245 Solvers
-
Sum of odd numbers in a matrix
620 Solvers
More from this Author21
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
Hello, are you sure you mean decreasing order when sorting A? Example, testsuite and your own solution suggest increasing order (ascending order to be strict) which is default in function sort
you are right ı fixed, thanks
I wouldn't call this problem N-dimensional sorting, unless we were sorting with different dimensions (the entire test suite only uses the first dimension). And the sort command does allow choosing the dimension currently, so I am not sure what it means when the problem description states that sort does not work as dimensions increases. Is the problem outdated?