フィルターのクリア

Delete rows that contains []

13 ビュー (過去 30 日間)
Alfonso Lopez
Alfonso Lopez 2015 年 11 月 25 日
コメント済み: Alfonso Lopez 2015 年 11 月 25 日
Hi
I would like to delete rows that contains [ ].
Thanks very much.
[ ] 1 NaN
[ ] 1 NaN
[ ] 1 NaN
[ ] 1 NaN
[ ] 1 0
'o_c' 1 1
'w_c' 1 1

採用された回答

Andrei Bobrov
Andrei Bobrov 2015 年 11 月 25 日
x = {[ ] 1 NaN
[ ] 1 NaN
[ ] 1 NaN
[ ] 1 NaN
[ ] 1 0
'o_c' 1 1
'w_c' 1 1};
out = x(~any(cellfun(@(x)isempty(x),x),2),:);
  2 件のコメント
Thorsten
Thorsten 2015 年 11 月 25 日
Or
out = x(~any(cellfun(@isempty,x),2),:)
Alfonso Lopez
Alfonso Lopez 2015 年 11 月 25 日
OMG!! Thanks very much. I was trying to do this almost all morning :)

サインインしてコメントする。

その他の回答 (1 件)

Guillaume
Guillaume 2015 年 11 月 25 日
c = {[] 1 NaN
[] 1 NaN
[] 1 NaN
[] 1 NaN
[] 1 0
'o_c' 1 1
'w_c' 1 1};
You get the cells of the cell array that are empty by using isempty on each cell. You can use cellfun to check each cell. You can then use any on each row (2nd dimension) of the cell array to delete rows that have any cell empty:
c(any(cellfun(@isempty, c), 2), :) = []
  1 件のコメント
Alfonso Lopez
Alfonso Lopez 2015 年 11 月 25 日
The same result as Andrei suggestion. Thanks very much too :)

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeWhos についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by