According to the profiler, I have four lines of code taking up 99% of my CPU time.
pCond = (bold_Phi(k,2) <= data(thisIdx : idx, 7));
pCond = (data(thisIdx : idx, 7) <= bold_Phi(k,2));
IDY = find( (data(thisIdx : idx, 1) == -1) & (pCond) & (data(thisIdx : idx, 11) == bold_Phi(k,p + 10)) );
IDZ = find( (dV(thisIdx : idx, :) <= -bold_Phi(k,3)) & (pCond) & (sCond) );
where bold_Phi and data are 2D matrices and dV is a vector.
I dont think the time penalty is coming from the indexing as the following statement is very quick
~isnan(data(thisIdx : idx, 3));
anything obvious I have missed that will help me speed up these few statements?