how to create group from matrix
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
hi, i want to do table group :
1 column :3,5,9,12
2 column: 4,6,7,8,10,11
3 colum (no..because this element are identical at colum 1 )
..
the column with all zero element to be not insert! (and the column egual )
finally i get this matrix (colum 5,6,7,8 are clone...i not insert it in the group)
1 column :3,5,9,12,0,0
2 column: 4,6,7,8,10,11
i try to use world reserved "unique" but i can't do it
0 commentaires
Réponse acceptée
Voss
le 7 Août 2023
Modifié(e) : Voss
le 7 Août 2023
M = [0 0 3 4 3 4 4 4; 0 0 5 6 5 6 6 6; 0 0 9 7 9 7 7 7; 0 0 12 8 12 8 8 8; 0 0 0 10 0 10 10 10; 0 0 0 11 0 11 11 11; 0 0 0 0 0 0 0 0; 0 0 0 0 0 0 0 0; 0 0 0 0 0 0 0 0]
% unique() by column:
M = unique(M.','rows','stable').'
% remove all-0 rows:
M(all(M == 0,2),:) = [];
% remove all-0 columns:
M(:,all(M == 0,1)) = [];
disp(M);
4 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Matrices and Arrays dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!