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

1 次查看(过去 30 天)
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)

类别

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