The code below works great for small vectors.
[X1, X2]=meshgrid(Data1(:,1), Data2(:,1));
[Y1, Y2]=meshgrid(Data1(:,2), Data2(:,2));
[Z1, Z2]=meshgrid(Data1(:,3), Data2(:,3));
Rxy = sqrt( (X1-X2).^2 + (Y1-Y2).^2 );
Rz = abs( Z1-Z2 );
[I1, I2] =find( Rxy<=100 & Rz<=0.2);
However, as I work with a large amount of data, matlab does not support and does not work correctly. Matlab generates the following message:
Error using repmat Requested 75027x68517 (38.3GB) array exceeds maximum array size preference. Creation of arrays greater than this limit may take a long time and cause MATLAB to Become unresponsive. See array size limit or preference panel for more information.
Seeking alternatives to "out of memory error," but I'm not getting an efficient manner. I made a loop to function is, but it was extremely slow.
repmat. Try to not use repmat to replicate arrays. See here. Also, if you feel using loop is costing you time, why don't you write a MEX-file, which will save you time. - Autonomous