How can I extract rows using column values?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Jacob Ebilane
le 22 Mai 2022
Commenté : Jacob Ebilane
le 22 Mai 2022
I'm trying to use the emnist byclass data set which includes digits and upper/lower case letters. I don't need all of the letters so I wanted to remove the unnecessary ones. The emnist set uses the first column as a label 0-61 and only need for example 0-9 and <49, 55, 11, 32, 13, 29, 30, 20, 33, 43, 24> these ones.
0 commentaires
Réponse acceptée
Walter Roberson
le 22 Mai 2022
classes_needed = [49, 55, 11, 32, 13, 29, 30, 20, 33, 43, 24];
mask = ismember(emnist(:,1), classes_needed);
subset = emnist(mask,:);
Plus de réponses (1)
MJFcoNaN
le 22 Mai 2022
% random matrix
A=randi(50,10)
% needed lines index
ind=ismember(A(:,1), [0:9, 49, 55, 11, 32, 13, 29, 30, 20, 33, 43, 24]);
% needed rows
B=A(ind, :)
0 commentaires
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!