How can I extract rows using column values?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Jacob Ebilane
il 22 Mag 2022
Commentato: Jacob Ebilane
il 22 Mag 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 Commenti
Risposta accettata
Walter Roberson
il 22 Mag 2022
classes_needed = [49, 55, 11, 32, 13, 29, 30, 20, 33, 43, 24];
mask = ismember(emnist(:,1), classes_needed);
subset = emnist(mask,:);
Più risposte (1)
MJFcoNaN
il 22 Mag 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 Commenti
Vedere anche
Categorie
Scopri di più su Resizing and Reshaping Matrices 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!