vectorization - Improve code / remove for-loop when using accumarray MATLAB -


i have following piece of code quite slow compute percentiles data set ("data"), because input matrices large ("data" approx. 500.000 long 10080 unique values assigned "indices").

is there possibility/suggestions make piece of code more efficient? example, somehow omit for-loop?

k = 1; = 0:0.5:100; % in 0.5 fractile-steps      fractile(:,k) = accumarray(indices,data,[], @(x) prctile(x,i));      k = k+1; end 

calling prctile again , again same data causing performance issues. call once each data set:

fractile=cell2mat(accumarray(indices,data,[], @(x) {prctile(x,[0:0.5:100])})); 

letting prctile evaluate 201 percentiles in 1 call costs computation time 2 iterations of original code. first because prctile faster way , secondly because accumarray called once now.


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -