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

1 vue (au cours des 30 derniers jours)
i have a vector and need to find the postions which has negative values

Réponse acceptée

Birdman
Birdman le 17 Fév 2018
Modifié(e) : Birdman le 17 Fév 2018
Say your vector is A:
idx=find(A<0)
ANeg=A(idx)

Plus de réponses (1)

Stephen23
Stephen23 le 17 Fév 2018
find is not required, logical indexing is simpler and more efficient:
B = A(A<0)
  2 commentaires
Birdman
Birdman le 17 Fév 2018
need to find the postions 
The user wants it.
Stephen23
Stephen23 le 19 Fév 2018
And logical indexing indexing gives it.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by