how to reduce the execution time of xcorr() function?
Show older comments
I want to find the windowed correlation values of x & y having array size of 1*20000. Xcorr function taking too much time to execute. Is there any way to reduce the execution time. The code is given below
k=1;
for i=1:stepsize:(length(x)-w+1)
corrValue_w=xcorr(x(i:i+w-1),y(i:i+w-1));
maxCorrValue_w(k)=max(corrValue_w);
k=k+1;
end
7 Comments
KSSV
on 26 Feb 2019
YOu reshape your data and use xcorr at once.
Sangeetha R
on 26 Feb 2019
Jan
on 26 Feb 2019
This does not work:
C = xcorr(reshape(x, w, :), reshape(y, w, :));
result = max(C, [], 1);
Sangeetha R
on 27 Feb 2019
Edited: Sangeetha R
on 27 Feb 2019
Jan
on 27 Feb 2019
This can be done easily with a loop, or with the buffer command: https://www.mathworks.com/help/signal/ref/buffer.html
Sangeetha R
on 28 Feb 2019
Jan
on 28 Feb 2019
@Sangeetha R: Please post this as an anser and "accept" it as solution.
Accepted Answer
More Answers (0)
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!