필터 지우기
필터 지우기

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 CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by