The function for determining the position of a given value in an array.
3 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!