Vectorizing the loop
Ältere Kommentare anzeigen
This code is similar to the histc function, but each element has weights associated with it. I'm looking to either use an alternate function or to vectorize it to make things faster
I have arrays A and B, and w is an array of weights associated with each element in A.
I'm hoping to calculate:
for i=1:length(B)
x(i) = sum((A>B(i)).*w)
end
Any help is appreciated. Thanks.
5 Kommentare
Junaid
am 24 Apr. 2012
I think it can be done, could you show small examples for A, B, w.
Nirmal
am 24 Apr. 2012
Walter Roberson
am 24 Apr. 2012
cumsum(histc(...)) .* w ??
Nirmal
am 24 Apr. 2012
Sean de Wolski
am 24 Apr. 2012
+1
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu MATLAB 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!