フィルターのクリア

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

28 ビュー (過去 30 日間)
ha ha
ha ha 2017 年 11 月 27 日
編集済み: Stephen23 2020 年 4 月 13 日
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),:) = []
Birdman
Birdman 2018 年 3 月 20 日
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),:)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by