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

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 ]

 채택된 답변

ha ha
ha ha 2018년 3월 20일
Thank @Stephen Cobeldick
A(any(isinf(A),2),:) = []

추가 답변 (2개)

Birdman
Birdman 2017년 11월 27일
편집: Birdman 2017년 11월 27일
[r,c]=find(ismember(A,Inf));
A(r,:)=[]

댓글 수: 2

Stephen23
Stephen23 2018년 3월 20일
편집: Stephen23 2020년 4월 13일
Logical indexing on one line:
A(any(isinf(A),2),:) = []
This is a very old answer of mine. Now I won't do that. :)

댓글을 달려면 로그인하십시오.

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

카테고리

도움말 센터File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

질문:

2017년 11월 27일

편집:

2020년 4월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by