How can I extract rows using column values?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Jacob Ebilane
am 22 Mai 2022
Kommentiert: Jacob Ebilane
am 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 Kommentare
Akzeptierte Antwort
Walter Roberson
am 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,:);
Weitere Antworten (1)
MJFcoNaN
am 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 Kommentare
Siehe auch
Kategorien
Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!