MATLAB Answers

Vecorize search for pattern

1 view (last 30 days)
Florian
Florian on 20 Aug 2013
Hello, I am trying to find patterns within longer series of data. So far I have done this in a loop, but I need to search larger matrices. Below is a simple example. I have tried to vectorize but so far without success meaning the code did not really get faster - any idea? Is there a matlab build in function which does that?
Simple example:
o_data=rand(1000,20);
patt= o_data(1:10,:);
for ii=1:size(patt,2)
for i=1:size(o_data,1)-size(patt,1)
close_index(i)=mean(abs(patt(:,ii)-o_data(i:i+size(patt,1)-1,ii)));
end
[vals ix]=sort(close_index);
closest_ten(ii,:)=ix(1:10);
end

  0 Comments

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!