replace [ ] in an array with 0's

3 visualizaciones (últimos 30 días)
alpedhuez
alpedhuez el 7 de Jul. de 2020
Editada: alpedhuez el 7 de Jul. de 2020
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?

Respuesta aceptada

Image Analyst
Image Analyst el 7 de Jul. de 2020
tables use functions like ismissing() and fillmissing():
newTable = fillmissing(badTable, 'constant', 0)
  1 comentario
alpedhuez
alpedhuez el 7 de Jul. de 2020
Editada: alpedhuez el 7 de Jul. de 2020
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);

Iniciar sesión para comentar.

Más respuestas (2)

KSSV
KSSV el 7 de Jul. de 2020
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 comentario
alpedhuez
alpedhuez el 7 de Jul. de 2020
Editada: alpedhuez el 7 de Jul. de 2020
Did not work with table

Iniciar sesión para comentar.


KSSV
KSSV el 7 de Jul. de 2020
You run on each column of a table..
  5 comentarios
dpb
dpb el 7 de Jul. de 2020
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 el 7 de Jul. de 2020
it worked

Iniciar sesión para comentar.

Categorías

Más información sobre Logical en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by