필터 지우기
필터 지우기

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by