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에서 Bartlett에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!