Hi
I have some code, which when I examine using the Matlab Profiler shows that the majority of the time is spent on the intersect and setdiff functions, which are invoked many times during a looping process. I was wondering if there was a clever way to speed this up? For example is it possible to somehow vectorize the following code to avoid invoking the inbuilt set functions? Thanks for your help!
tic;size=50000;a=round(100*rand(size,1));b=round(100*rand(size,1));intersect(a,b);setdiff(a,b);toc;
Best Answer