Storing indices from a matrix

조회 수: 10 (최근 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개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by