Domanda

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

È stato utile?

Soluzione

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)), :)

Altri suggerimenti

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
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top