
Store the subscripts of an array where a condition is fulfilled

BRDF
For a 1-D array, I can use Extract/INDX, but for 2-D and 3-D arrays the stored index (1-D) is inconvenient, see the following example.
Thanks!
zh
function where() make/O/N=(5, 6) judge=p^2-q^2 make/O/N=(5, 6, 3) data1=p+q-r // *** my question starts here: how to quickly achieve the following results but without looping? variable i, j, k For(k=0; k<3; k+=1) For(j=0; j<6; j+=1) For(i=0; i<5; i+=1) data1[i][j][k]= ((judge[i][j]<=8)&&(judge[i][j]>=-8))? NaN : data1[i][j][k] Endfor Endfor Endfor // // *** my question ends here... // // Solution 1, use EXTRACT/INDX, but INDX is 1-D and thus not straightfoward to index data // // Solution 2, use question mark ? // data1[][][]=((judge[p][q]<=8)&&(judge[p][q]>=-8))? NaN : data1[p][q][r] // // then the question is: how to store the subscripts of an array where a condition is fulfilled without making // such a judgement every time? // For example, what if I have data2, data3,...., data100 that would need to satisfy the same condition as data1. // // Any other solutions, maybe MatrixOp?? // End
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
April 9, 2015 at 09:58 am - Permalink