How to delete entire row if any cell of the particular row is empty
35 ビュー (過去 30 日間)
古いコメントを表示
Mekala balaji
2016 年 3 月 4 日
コメント済み: Wolfgang McCormack
2021 年 3 月 13 日
Hi, I have the below cell array matrix. Some cells are empty, and I want to delete entire row if any cell is empty(Ex: 2, 3,4). And my final output should be only row1 & row5.
Index name1 name2 visit
1 MM_vrx_ty_98u prb05k 20
2 M_rx_ty_8u prbkv
3 prb05k 50
4 MM_vrx_ty_98u 11
5 GG_VL_ty_4u 9
Kindly help. Sincerely,
0 件のコメント
採用された回答
Walter Roberson
2016 年 3 月 4 日
row_has_empty = any(cellfun(@isempty, YourCell), 2); %find them
YourCell(row_has_empty,:) = []; %delete them
その他の回答 (1 件)
Pruthvi G
2019 年 3 月 26 日
Input :
Matrix = [[{'a'};{'b'};{'c'};{''};{'b'};{'c'}],[{'a'};{'b'};{''};{'a'};{''};{'c'}],[{'a'};{''};{'c'};{'a'};{'b'};{'c'}]]
Matrix =
6×3 cell array
'a' 'a' 'a'
'b' 'b' ''
'c' '' 'c'
'' 'a' 'a'
'b' '' 'b'
'c' 'c' 'c'
Solution to delete complete Row if Empty cell is found
% Answer
Empty_Matrix=cellfun('isempty',Master_BC)
Matrix(any(Empty_Matrix(:,[1,2,3]),2),:)=[] % deleting the entire row
Output :
Matrix =
2×3 cell array
'a' 'a' 'a'
'c' 'c' 'c'
2 件のコメント
参考
カテゴリ
Help Center および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!