Using find with a vector without having to use a for loop
Ältere Kommentare anzeigen
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 Kommentare
the cyclist
am 14 Mär. 2013
Why do you prefer not to use bsxfun? It seems well suited to the task.
Matlab2010
am 14 Mär. 2013
Friedrich
am 14 Mär. 2013
That is not true! BSXFUN is highly parallized under the hood. Fastest function you can get.
Jan
am 14 Mär. 2013
BSXFUN is not a slower version of a loop. I think ARRAYFUN could earn this description, especially when used with anonymous functions.
Matlab2010
am 28 Mär. 2013
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!