Quick vectorization question (for loop)
Ältere Kommentare anzeigen
Hi
This loop takes about 0.085 seconds to execute and needs to be executed several thousand times. Is there a way you think I can vectorize this? I really appreciate any help!
wsize = 20;
vin = rand(1200,1);
for idx = wsize:length(vin)
mstd(idx-wsize+1, :) = std(vin(idx-wsize+1:idx));
end
PS: I don't have Parallel Processing toolbox.
Akzeptierte Antwort
Weitere Antworten (1)
Image Analyst
am 27 Sep. 2012
1 Stimme
Do you have the Image Processing Toolbox? it looks like your code is a sliding window of a standard deviation filter. This is done by the function stdfilt() in the Image Processing Toolbox. Alternatively (if you don't have the Image Processing Toolbox) you could use an anonymous function and blockproc (I have a demo for that if you need it).
1 Kommentar
Matt Fig
am 27 Sep. 2012
I had never heard of stdfilt, IA. Thanks!
Kategorien
Mehr zu Blocked Images finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!