Borrar filtros
Borrar filtros

How to convert cell array with Nan to a double array with Nan=0?

11 visualizaciones (últimos 30 días)
Alexandria Will-Cole
Alexandria Will-Cole el 26 de Sept. de 2017
Comentada: Cedric el 26 de Sept. de 2017
I have imported data with NaN and other values all in one column. I need to convert this into a double array where all of NaNs are set to zero. Please help! Thanks!

Respuestas (1)

Cedric
Cedric el 26 de Sept. de 2017
Editada: Cedric el 26 de Sept. de 2017
x = cell2mat(C) ;
x(isnan(x)) = 0 ;
  2 comentarios
Alexandria Will-Cole
Alexandria Will-Cole el 26 de Sept. de 2017
x = cell2mat(val) ;
x(isnan(x)) = 0 ;
I get this error message:
Error using cat Dimensions of matrices being concatenated are not consistent.
Error in cell2mat (line 83) m{n} = cat(1,c{:,n});
Cedric
Cedric el 26 de Sept. de 2017
Then it's not all in one column I guess, but you have a cell array of vectors or a cell array of cell arrays. Can you copy/past part of the content?

Iniciar sesión para comentar.

Categorías

Más información sobre Data Type Conversion en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by