How can I extract rows using column values?
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Walter Roberson
2022-5-22
classes_needed = [49, 55, 11, 32, 13, 29, 30, 20, 33, 43, 24];
mask = ismember(emnist(:,1), classes_needed);
subset = emnist(mask,:);
更多回答(1 个)
MJFcoNaN
2022-5-22
% 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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!