I want to compare two-cell arrays (X and Y) field by field (each field is a 2-dimensional array of points) and for each comparison compute how many points overlap. However I have a condition that needs to be fulfilled in each instance (which depends on some numbers in an array). Which of the following approaches makes more sense (speed or other issues)? Is there even a significant difference?
edit: The condition to check consists of two number comparisons, i.e. if/find array(jj)>= 0.5*K && array(jj)<=2*K, where K is constant for one ii.
1. find indices beforehand and run the second for-loop only over those
for ii=1:N
idx = find(jj that fulfill CONDITION in array);
for jj=idx
matrix(ii,jj) = sum(ismember(X{ii}, Y{jj}));
end
end
2. run for-loop over all indices and check condition individually with an if-clause
for ii=1:N
for jj=1:M
if Y(jj) fulfills CONDITION in array
matrix(ii,jj) = sum(ismember(X{ii}, Y{jj}));
end
end
end