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

15 次查看(过去 30 天)
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,:)=[]

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

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

标签

尚未输入任何标签。

Community Treasure Hunt

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

Start Hunting!

Translated by