for i = 1 : size(X,1) for j = 1 : size(Y,1) if X(i,1)>= Y(j,1) && X(i,2) <= Y(j,2) Z(i,1:2)=X(i,:); Z(i,3:4)=Y(j,:); end
It works but it is not fast. The problem is X and Y must contain thousands of datas. So I would like to avoid the for loops. I asked someone to give a try to the solution with bsxfun and it works with its Matlab versions but, according to him, it is slower than my original_event function. So I don't know what to do but I would like to know if there a possiblity to avoid any loops, or to combine them in some ways.