Question
How can I use randperm for a nx2 matrix?
Expert Answer
John Williams
PhD Expert
Answered Aug 26, 2026
"randperm" only takes 1 scalar input argument. Can you give a sample of an input nx2 matrix AND what you would expect the output to be?
If you want to randomly permute the rows, do something like the following.
n = 5;
A = reshape(1:2*n, n, 2)
B = A(randperm(n), :)
if you want to randomly permute all elements, do something like this instead.
C = reshape(A(randperm(2*n)), n, 2)
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
Related MATLAB Questions & Solutions
Browse All →
Explore similar technical troubleshooting questions and verified MATLAB solutions:
Ready-to-Run MATLAB & Simulink Projects
Browse All Projects →