문제

I want to shuffle my data row wise (in a single unique row there will be no shuffling, it has to remain the same - I mean all individual cells in a single row can not change). The number of rows I have in my excel files is around 170000.

All I need is to shuffle randomly all the rows among them. How can I do this by mat-lab commands? Codes or algorithm please!

enter image description here

도움이 되었습니까?

해결책

For reading and writing excel files see xlsread and xlswrite.

To randomly shuffle the rows of a matrix:

M = magic(5);
Mshuffled = M(randperm(size(M, 1)), :)

다른 팁

As mentioned by @Dan, you can use xlsread and xlswrite for manipulation of Excel files. You could use randperm to achieve shuffling effectively, but another way to achieve this would be using the randsample command.

For example:

>> A = randint (5,2,[1,10])

A =

     2     2
    10     5
    10    10
     5     8
     9    10

>> A(randsample(1:size(A,1),size(A,1)),:)

ans =

    10     5
     2     2
     9    10
    10    10
     5     8
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top