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

16 vues (au cours des 30 derniers jours)
ha ha
ha ha le 27 Nov 2017
Modifié(e) : Stephen23 le 13 Avr 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 ]

Réponse acceptée

ha ha
ha ha le 20 Mar 2018
Thank @Stephen Cobeldick
A(any(isinf(A),2),:) = []

Plus de réponses (2)

Birdman
Birdman le 27 Nov 2017
Modifié(e) : Birdman le 27 Nov 2017
[r,c]=find(ismember(A,Inf));
A(r,:)=[]
  2 commentaires
Stephen23
Stephen23 le 20 Mar 2018
Modifié(e) : Stephen23 le 13 Avr 2020
Logical indexing on one line:
A(any(isinf(A),2),:) = []
Birdman
Birdman le 20 Mar 2018
This is a very old answer of mine. Now I won't do that. :)

Connectez-vous pour commenter.


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

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Tags

Aucun tag saisi pour le moment.

Community Treasure Hunt

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

Start Hunting!

Translated by