Could anyone help me to solve the following issue
1 view (last 30 days)
Show older comments
Code:
a = [1 2 3 4 5;
6 7 8 9 10]
a_rand = a(randperm(length(a)))
When i run the above two commands it executes and gives the following result
a_rand = 3 6 2 7 1
But in this result i can get only one row .
Coud anyone help me how to get two rows with the left out numbers displaying at the second row.
0 Comments
Answers (2)
KSSV
on 3 Jun 2019
a = [1 2 3 4 5;
6 7 8 9 10] ;
idx1 = (randperm(length(a))) ;
idx2 = setdiff(1:numel(a),idx1) ;
iwant = [a(idx1) ; a(idx2)]
4 Comments
See Also
Categories
Find more on Language Fundamentals in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!