フィルターのクリア

Remove row of cell array that contains 0.

4 ビュー (過去 30 日間)
Chin
Chin 2012 年 1 月 16 日
For example, I have a = [{0} {0} {0}; {1} {3} {4}; {0} {0} {0}]. I would like to remove the row that contains all of zero so that I can have the result a = [{1} {3} {4}]. I try this but it not work.
a(all(a == 0, 2), :) = []
what I am missing? Thanks.

採用された回答

Andrei Bobrov
Andrei Bobrov 2012 年 1 月 16 日
out = a(all(cellfun(@(x)x~=0,a),2),:);
OR
out = a(all(cell2mat(a) ~= 0,2),:);
  1 件のコメント
Chin
Chin 2012 年 2 月 14 日
I would like to know if my cell array is a = [{0} {2} {3}; {0} {4} {5}; {0} {7} {3}], how do i delete the column that contains all of 0? thanks again.

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by