How to find which postions in a vector has negative values and output them?

1 回表示 (過去 30 日間)
sairohith mudduluru
sairohith mudduluru 2018 年 2 月 17 日
コメント済み: Stephen23 2018 年 2 月 19 日
i have a vector and need to find the postions which has negative values

採用された回答

Birdman
Birdman 2018 年 2 月 17 日
編集済み: Birdman 2018 年 2 月 17 日
Say your vector is A:
idx=find(A<0)
ANeg=A(idx)

その他の回答 (1 件)

Stephen23
Stephen23 2018 年 2 月 17 日
find is not required, logical indexing is simpler and more efficient:
B = A(A<0)
  2 件のコメント
Birdman
Birdman 2018 年 2 月 17 日
need to find the postions 
The user wants it.
Stephen23
Stephen23 2018 年 2 月 19 日
And logical indexing indexing gives it.

サインインしてコメントする。

カテゴリ

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