Place blank entries by zeros

조회 수: 1 (최근 30일)
Maria
Maria 2014년 8월 14일
댓글: dpb 2014년 8월 14일
I have a cell type variable with 5000 rows and 8 cells. For example:
a={182 1999 63,8 229 [] 30 [] 1
185 1999 44,5 123 19,7 51 [] []
194 1999 50,7 273 [] 44 [] 1
195 1999 53,2 [] [] [] [] []}
And I would like to substitute the blank entries in the last column only by zero so I would get:
a={182 1999 63,8 229 [] 30 [] 1
185 1999 44,5 123 19,7 51 [] 0
194 1999 50,7 273 [] 44 [] 1
195 1999 53,2 [] [] [] [] 0}
I tried something like this, but is not working:
a(cellfun(@isempty,a(:,8))) = {0};
Can someone help me? Thank you
  댓글 수: 1
dpb
dpb 2014년 8월 14일
Ahhh....my old eyes missed the missing column addressing index...couldn't see the difference at first.

댓글을 달려면 로그인하십시오.

채택된 답변

Adam
Adam 2014년 8월 14일
a( cellfun(@isempty,a(:,8)),8 ) = {0}

추가 답변 (1개)

dpb
dpb 2014년 8월 14일
a(cellfun(@isempty,a(:,end)),end)={0}
worked here...had to convert the ',' decimal points to '.' to enter the array, however...

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by