if-else procedure
Vinni
Dear all,
I would like to write a procedure using if-else on a large dataset. I have 1000*25 data matrix (Dij). I want to create another matrix (Aij) with same dimension by doing the following calculation for each data point:
if Dij< Bj
Aij= 5/6* Bj
else
Aij= square root ((Pj*Dij)^2+(Bj)^2)
Where, Bj and Pj are single column waves.
Please help with procedure writing in Igor 6.37 version.
I don't remember when it was introduced, but in recent versions of Igor you can use ? : as a short form conditional in wave assignments.
In Igor you use p and q to refer to the row and column index of the wave on the left hand side of the assignment statement.
so
A[][] = D[p][q] < B[q] ? 5/6*B[q] : sqrt( (P[q]*D[p][q])^2 + B[q]^2 )
July 9, 2020 at 02:37 am - Permalink
In reply to I don't remember when it was… by tony
With a large matrix the conditional [p][q] method might be slow. I suggest you look at the MatrixOp options. There are functions for sqrt(z), greater(a,b), and all the other usual matrix and vector multiplications.
July 9, 2020 at 04:26 am - Permalink
And don't forget Multithread for the wave assignment.
July 10, 2020 at 04:53 am - Permalink
Thank you so much everyone! It worked.
July 15, 2020 at 02:00 am - Permalink