talks about replace [] with 0's for one column. But suppose I have a table with many columns and I want to run this operation for multiple colmns. Is there any way simpler than writing another loop?

 채택된 답변

Image Analyst
Image Analyst 2020년 7월 7일

0 개 추천

tables use functions like ismissing() and fillmissing():
newTable = fillmissing(badTable, 'constant', 0)

댓글 수: 1

alpedhuez
alpedhuez 2020년 7월 7일
편집: alpedhuez 2020년 7월 7일
Invalid fill constant type.
[intConstVj,extMethodVj] = checkArrayType(Avj,intMethod,intConstVj,extMethodVj,x,true,ma);
B.(vj) = fillTableVar(indVj,A.(vj),intMethod,intConst,extMethod,x,useJthFillConstant,useJthExtrapConstant,mavj);
B = fillTable(A,intM,intConstOrWinSize,extM,x,dataVars,ma);

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

추가 답변 (2개)

KSSV
KSSV 2020년 7월 7일

1 개 추천

You can get all the emtpy functions in a cell using cellfun ..
idx = cellfun(@isempty,C) ; % get empty cells in a cell array C
C(idx) = 0 ; % replace with zero
Note that, cellfun also uses loop inside.

댓글 수: 1

alpedhuez
alpedhuez 2020년 7월 7일
편집: alpedhuez 2020년 7월 7일
Did not work with table

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

KSSV
KSSV 2020년 7월 7일

0 개 추천

You run on each column of a table..

댓글 수: 5

alpedhuez
alpedhuez 2020년 7월 7일
lots of columns...
dpb
dpb 2020년 7월 7일
You can also address table columns numerically using all the other addressing manners, loops, colon, etc., etc., etc., ...
alpedhuez
alpedhuez 2020년 7월 7일
편집: alpedhuez 2020년 7월 7일
For table T, for column 3 to 5, is it like
for j=3:5 % column
for i = 1:length(T) % row
if isempty(T(i,j))
T(i,j) = 0;
end
end
end
?
dpb
dpb 2020년 7월 7일
Did you try it? I dunno, don't have your table but can only have empty [] in cell array so the table column content must be a cell it would seem...
Again, w/o a sample piece of data to work on it's tough...
alpedhuez
alpedhuez 2020년 7월 7일
it worked

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

카테고리

도움말 센터File Exchange에서 Structures에 대해 자세히 알아보기

질문:

2020년 7월 7일

편집:

2020년 7월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by