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

16 Ansichten (letzte 30 Tage)
ha ha
ha ha am 27 Nov. 2017
Bearbeitet: Stephen23 am 13 Apr. 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 ]

Akzeptierte Antwort

ha ha
ha ha am 20 Mär. 2018
Thank @Stephen Cobeldick
A(any(isinf(A),2),:) = []

Weitere Antworten (2)

Birdman
Birdman am 27 Nov. 2017
Bearbeitet: Birdman am 27 Nov. 2017
[r,c]=find(ismember(A,Inf));
A(r,:)=[]
  2 Kommentare
Stephen23
Stephen23 am 20 Mär. 2018
Bearbeitet: Stephen23 am 13 Apr. 2020
Logical indexing on one line:
A(any(isinf(A),2),:) = []
Birdman
Birdman am 20 Mär. 2018
This is a very old answer of mine. Now I won't do that. :)

Melden Sie sich an, um zu kommentieren.


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

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Tags

Noch keine Tags eingegeben.

Community Treasure Hunt

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

Start Hunting!

Translated by