Using find with a vector without having to use a for loop
显示 更早的评论
I have code which does
for t = 1: length(vector2)
idx(t) = find(vector <=vector2(t), 1, 'last');
end
Can I call find.m without using a for loop (or bsxfun.m) and if so how?
Or should I just use histc?
[~,idx]=histc(vector2, vector);
5 个评论
the cyclist
2013-3-14
Why do you prefer not to use bsxfun? It seems well suited to the task.
Matlab2010
2013-3-14
Friedrich
2013-3-14
That is not true! BSXFUN is highly parallized under the hood. Fastest function you can get.
Jan
2013-3-14
BSXFUN is not a slower version of a loop. I think ARRAYFUN could earn this description, especially when used with anonymous functions.
Matlab2010
2013-3-28
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!