Info
此问题已关闭。 请重新打开它进行编辑或回答。
How to get the indices of the rows of the matrix which are shuffled ?
1 次查看(过去 30 天)
显示 更早的评论
I have a matrix A , which i have shuffled. Now how to get the indices of the rows which were shuffled . Just like the command 'sort' gives the indices of the elements sorted. Similarly , is there a command which would give me the indices of the rows interchanged. Please suggest . Thanks
function trial
A=[3 2 1;4 5 6;6 7 8];
shuffledArray = A(randperm(size(A,1)),:)
end
2 个评论
per isakson
2017-11-18
编辑:per isakson
2017-11-18
>> A
A =
3 2 1
4 5 6
6 7 8
>> ix = randperm(size(A,1))
ix =
3 1 2
>> A(ix,:)
ans =
6 7 8
3 2 1
4 5 6
Isn't it ix you are looking for?
回答(1 个)
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!