How to delete nan from array

B=[nan 8 nan;6 nan nan;6 5 8] C=[nan 4 nan;4 nan nan;5 3 2]
Answer: B=[8 6 6 5 8] C=[4 4 5 3 2]

 Respuesta aceptada

Guillaume
Guillaume el 13 de En. de 2015
Editada: Guillaume el 13 de En. de 2015

5 votos

B = B';
B = B(~isnan(B))';
C = C';
C = C(~isnan(C))';

3 comentarios

Adam
Adam el 13 de En. de 2015
You need a reassignment to B and C too in there:
B = B(~isnan(B))';
C = C(~isnan(C))';
Guillaume
Guillaume el 13 de En. de 2015
Yes, not sure what I was thinking.
Yang Liu
Yang Liu el 4 de Ag. de 2022
Why use '? Why not just B=B(~isnan(B))?

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Data Type Conversion en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 13 de En. de 2015

Comentada:

el 4 de Ag. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by