How to find the position of the first non-zero element of my matrix?

418 ビュー (過去 30 日間)
Leon
Leon 2020 年 3 月 10 日
コメント済み: Leon 2020 年 3 月 10 日
For example, if I have a column data like the below:
A = [0; 1; 0; 0; 0];
The answer would be 2.
For the below example:
B = [ 0; 0; 1; 0; 1; 0; 0];
The answer would be 3.
Is there a function to do that quickly?

採用された回答

Stephen23
Stephen23 2020 年 3 月 10 日
編集済み: Stephen23 2020 年 3 月 10 日
find(yourVector,1,'first')

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by