if-else procedure

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 )

 

In reply to 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.