How to permute the rows and columns in a matrix ?
44 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Nguyen Trong Nhan
il 30 Dic 2013
Risposto: Daniel Morais
il 21 Mar 2017
for example: I have matrix A: A = [1 2 3 4;5 6 7 8;9 10 11 12;13 14 15 16] how to permute between column 1 and column 4 ? how to permute between row 1 and row 3 ? thanks
0 Commenti
Risposta accettata
Wayne King
il 30 Dic 2013
Modificato: Wayne King
il 30 Dic 2013
Swapping the columns
idx = [4 2 3 1];
B = A(:,idx);
Swapping the rows
idx = [3 2 1 4];
C = A(idx,:);
0 Commenti
Più risposte (2)
Daniel Morais
il 21 Mar 2017
Utilize x = x( : , randperm(c)), onde x é a matriz e c o número de colunas de x. O mesmo vale para a permutação de linhas: x = x( randperm(l) , : ) onde l é o número de linhas.
0 Commenti
Vedere anche
Categorie
Scopri di più su General Applications in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!