Storing indices from a matrix

27 ビュー (過去 30 日間)
shahzer rahman
shahzer rahman 2020 年 3 月 2 日
コメント済み: shahzer rahman 2020 年 3 月 2 日
Hye all. I am relatively new with Matlab. I am modelling a vehicle suspension system right now.
Assume I have a column matrix that has 6 elements. A= [ 1 2 3 -4 6 -2]'
I want to extract the index of the values that are negative, and store all of them as a column matrix or an array 'B'.
Expected result : B= [4 6]
Kindly help.

採用された回答

Stephan
Stephan 2020 年 3 月 2 日
編集済み: Stephan 2020 年 3 月 2 日
A= [ 1 2 3 -4 6 -2]'
B = find(A<0)
A =
1
2
3
-4
6
-2
B =
4
6
  1 件のコメント
shahzer rahman
shahzer rahman 2020 年 3 月 2 日
Thanks man. works fine.

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by