フィルターのクリア

The function for determining the position of a given value in an array.

3 ビュー (過去 30 日間)
liangjian
liangjian 2011 年 11 月 11 日
I have an array storing numerical values, I know the last part of this array are all zero values. How can I find the starting position of this part? In other words, I would like to find the starting position of 0 in this array. Which function should I use?

採用された回答

Wayne King
Wayne King 2011 年 11 月 11 日
x = ones(1e3,1);
x(750:end) = 0;
index = find(x == 0,1);
If you want to find the first K values.
K = 3;
indices = find(x==0,K,'first');
so
index = find(x == 0,1);
is equivalent to
index = find(x == 0,1,'first');

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by