How to sort a matrix in a random order?

E
Evangeline · Nov 19, 2020 · 2K views
Question
How to sort a matrix in random order?  
Expert Answer
Profile picture of Neeta Dsouza
Neeta Dsouza PhD Expert
Answered Aug 26, 2026
>> x = reshape(1:24,4,6)
x =
     1     5     9    13    17    21
     2     6    10    14    18    22
     3     7    11    15    19    23
     4     8    12    16    20    24
>> x(:) = x(randperm(numel(x)))
x =
     7    12     3    19    16    23
    20    24    10    11     1    17
    21    14     8     5    13    18
     6    22    15     4     2     9
100% Run Guarantee 3-Hour Fast-Track Delivery

Need a Custom Version or Complete Simulation for This Problem?

Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.

Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!