How remove NaN values in all Matrices in Cell

1 visualización (últimos 30 días)
Robin
Robin el 8 de Ag. de 2017
Comentada: Robin el 8 de Ag. de 2017
I have a cell like:
c{1}= [1 1 1;
2 2 2;
3 3 3;
N N N;
N N N]
c{2}= [1 1 1;
100 2 2;
200 3 3;
300 4 5;
N N N]
N stands for NaN
Where the matrix in each cell has the same size but the amount of NaN values vary. Is there like a fancy vectorizing function using cellfun or maybe even a loop solution? The matrices are gpu arrays! I tried heaps of solutions but i couldnt find a working one. If this is duplicate im sorry!
kindly regards robin
  1 comentario
José-Luis
José-Luis el 8 de Ag. de 2017
Will the entire row always consist of NaNs? If not, how do you want to do the removal?

Iniciar sesión para comentar.

Respuesta aceptada

José-Luis
José-Luis el 8 de Ag. de 2017
Editada: José-Luis el 8 de Ag. de 2017
This will get rid of the entire row if there is a NaN:
c{1}= [1 1 1;
2 2 2;
3 3 3;
NaN NaN NaN;
NaN NaN NaN];
c{2}= [1 1 1;
100 2 2;
200 3 3;
300 4 5;
NaN NaN NaN]
cellfun(@(x) {x(sum(~isnan(x),2)>0,:)},c)

Más respuestas (0)

Categorías

Más información sobre Matrices and Arrays 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