Effacer les filtres
Effacer les filtres

Extract from lines from matrix that do not contain NaN

2 vues (au cours des 30 derniers jours)
Lily
Lily le 11 Oct 2012
Hi
I'm trying to ignore NAN from my matrix A and only use the lines that contain numbers. For expamle if my matrix is:
A = [0.02, 1.28, 0.22; 0.01, 0.64, 0.12; 0, NaN, NaN; 0, NaN, 0.05; 0, NaN, NaN];
Here I would only like to extract the following data from the matrix A:
A_extract = [0.02, 1.28, 0.22; 0.01, 0.64, 0.12];
Is it possible to do a general solution for this problem?

Réponse acceptée

Matt J
Matt J le 11 Oct 2012
A_extract=A(~any(isnan(A),2),:)
  1 commentaire
Lily
Lily le 11 Oct 2012
Modifié(e) : Lily le 11 Oct 2012
Thx so much for this :)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by