delete row in matrix if the row contain "Inf" value

33 visualizaciones (últimos 30 días)
ha ha
ha ha el 27 de Nov. de 2017
Editada: Stephen23 el 13 de Abr. de 2020
Let's say:
A=[1 2 3 5
2 Inf Inf Inf ---->delete this row
3 1 7 5
9 Inf Inf Inf ---->delete this row
11 3 45 91 ]
Question: If i want to delete the row contain "Inf", how can I do that?
result_A=[1 2 3 5
3 1 7 5
11 3 45 91 ]

Respuesta aceptada

ha ha
ha ha el 20 de Mzo. de 2018
Thank @Stephen Cobeldick
A(any(isinf(A),2),:) = []

Más respuestas (2)

Birdman
Birdman el 27 de Nov. de 2017
Editada: Birdman el 27 de Nov. de 2017
[r,c]=find(ismember(A,Inf));
A(r,:)=[]
  2 comentarios
Stephen23
Stephen23 el 20 de Mzo. de 2018
Editada: Stephen23 el 13 de Abr. de 2020
Logical indexing on one line:
A(any(isinf(A),2),:) = []
Birdman
Birdman el 20 de Mzo. de 2018
This is a very old answer of mine. Now I won't do that. :)

Iniciar sesión para comentar.


LU Chongkai
LU Chongkai el 12 de Abr. de 2020
Here is a way that don't change the original matrix:
B = A(any(~isinf(A),2),:)

Categorías

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

Etiquetas

Aún no se han introducido etiquetas.

Community Treasure Hunt

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

Start Hunting!

Translated by