I currently have the code below, which essentially checks if each element of the MainArray is within any of the intervals described in each row of CompArray; if yes, the corresponding position in ResultsArray is set to 0. In practice, I need to run this on mich bigger matrices and iteratively, so speed of execution becomes a problem. Is there a possibility to vectorize it? Note that CompArray can have a variable number of rows (comparison intervals), but always only two columns.
ResultsArray = ones(10,10);
if(any((MainArray(Row,Col) >= CompArray(:,1)) & (MainArray(Row,Col) <= CompArray(:,2))))
ResultsArray(Row,Col) = 0;