N-Dimensional Sorting - MATLAB Cody - MATLAB Central

Problem 2344. N-Dimensional Sorting

Difficulty:Rate

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    28
 A(:,:,2) =
    13    35
    22     3
 B(:,:,1) =
    31    55
    26    38
 B(:,:,2) =
    59    51
    36    29
 Bsorted(:,:,1) =
    26    38
    31    55
 Bsorted(:,:,2) =
    59    29
    36    51

Solution Stats

66.67% Correct | 33.33% Incorrect
Last Solution submitted on Nov 28, 2021

Problem Comments

Solution Comments

Show comments
PIVlab surpasses 100K all-time File Exchange downloads
During the past twelve months, PIVlab, a MATLAB Community Toolbox for particle...
4
8
LLMs with MATLAB updated to support the latest OpenAI Models
Large Languge model with MATLAB, a free add-on that lets you access...
2
4

Problem Recent Solvers16

Suggested Problems

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!