How to get ones out of matrix

조회 수: 1 (최근 30일)
Kamil Kacer
Kamil Kacer 2020년 12월 3일
댓글: Kamil Kacer 2020년 12월 3일
Hi i have this matrix I want to write an if statement or use a function where i detect if there is any '1' in this sequence ant if it is i want to also give me at which position.

채택된 답변

KSSV
KSSV 2020년 12월 3일
a = [0 1 1 0] ;
idx = find(a==1)
idx = 1×2
2 3
  댓글 수: 3
Rik
Rik 2020년 12월 3일
If you insist on words, you probably need something like this.
Otherwise you can do this:
a = [0 1 1 0] ;
idx = find(a==1);
fprintf('frame %d\n',idx(1))
frame 2
Kamil Kacer
Kamil Kacer 2020년 12월 3일
I works perfectly i just put idx(:) instead of (1) and i get where all the ones are
Thaaaank youu

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Detection에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by