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 Center および File ExchangeDetection についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by