i want to delete cells that contain 0's
2 ビュー (過去 30 日間)
古いコメントを表示
Ioannis Vourvachakis
2021 年 11 月 24 日
コメント済み: Ioannis Vourvachakis
2021 年 11 月 24 日
In a cell array, there are rows of cells that contain 0's. I want to delete these rows.
Thank you.
0 件のコメント
採用された回答
Kevin Holly
2021 年 11 月 24 日
Assuming the values in cell array are numeric:
cellarray = {34 , 23, 4, 123, 0 ,423, 4312;34 , 23, 4, 123, 5 ,423, 4312;34 , 0, 0, 123, 5 ,423, 4312;34 , 73, 5, 13, 7 ,23, 43;34 , 22, 3, 125, 5 ,423, 4312}
out = cellfun(@(x) find(x == 0),cellarray,'un',0);
idx = cellfun('isempty',out);
[row, column] = find(~idx);
cellarray(row,:)=[]
3 件のコメント
Kevin Holly
2021 年 11 月 24 日
cellarray = {34 , 23, "ok", 123, 0 ,423, 4312;34 , 23, 4, 123, 5 ,"Words", 4312;34 , 0, 0, 123, 5 ,423, 4312;34 , 73, 5, 13, 7 ,"23", 43;34 , 22, 3, "125", 5 ,423, 4312}
out = cellfun(@(x) isnumeric(x) && x==0 ,cellarray,'un',0)
[row, column] = find(cell2mat(out))
cellarray(row,:)=[]
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!