How do I filter rows of a cell based on an empty column
2 次查看(过去 30 天)
显示 更早的评论
Say I have a 100x100 cell. I want to get all the rows where the 8th column is empty (equal to []), and also all the rows where the 8th column is not empty. These would be two separate variables.
How would I go about doing this?
0 个评论
采纳的回答
Akira Agata
2017-7-16
Similarly to your previous question, the code will be like:
% 100x100 sample cell array with randomly located empty cells
C = num2cell(randi(10,100,100));
idx = cellfun(@(x) isequal(x,3), C);
C(idx) = {''};
% Rows where the 8th column is empty
idx = cellfun(@isempty, C(:,8));
% Extract the target rows
C1 = C(idx,:);
% Others
C2 = C(~idx,:);
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!