Replacing NaN elements in a wave with a number

I have a 3D wave, waveA, where some of its elements are NaN. How can I replace all of these NaN elements with a numerical value, e.g. 100.0, without using loop?
I don't know what matrixop does behind the scenes but I suspect it is something like this, in other words, a hidden loop:

variable v_val = 99
waveA = (numtype(waveA[p]) == 2) ? v_val : waveA[p]


where v_val is the value you want to change the NaNs to (i.e. 99 in this case).

I don't know how the snippet is optimized internally by the igor pro interpreter, so it may be slower than using matrixop. But the snippet above allows you to build other logical functions/ filters for wave elements.

best,
_sk
Thanks for you both, it seems like matrixop is faster but it's also good to have other form of codes which does the same and can be generalized to another wave filtering operation.
It goes without saying that in 3D one would have to traverse over all dimensions, i.e.:
waveA = (numtype(waveA[p][q][r]) == 2) ? 99 : waveA

best,
_sk
_sk wrote:
I don't know what matrixop does behind the scenes but I suspect it is something like this, in other words, a hidden loop:

variable v_val = 99
waveA = (numtype(waveA[p]) == 2) ? v_val : waveA[p]


where v_val is the value you want to change the NaNs to (i.e. 99 in this case).

I don't know how the snippet is optimized internally by the igor pro interpreter, so it may be slower than using matrixop. But the snippet above allows you to build other logical functions/ filters for wave elements.

best,
_sk


Great!!
with mutithread key word,that is why Igor so powerfull!
Hey,
sorry for leaving this thread for one day without updating. So I what I want is actually to use interpolate3D to get the 3D wave and for points lying outside the domain of the source wave this command will return NaN. That's why in the end my 3D wave will contain some NaN elements. However, yesterday I noticed that with my source wave for triangulate3D (I need the output from this command to run the subsequent interpolate3D) being very large (2050401 rows and 4 cols), the execution time exceeded 24 hours until I aborted it before finish. I see someone mentioning MultiThread, looks like some parallel computation related term. Will it help speeding up triangulate3D?
tomy77 wrote:
Hey,
sorry for leaving this thread for one day without updating. So I what I want is actually to use interpolate3D to get the 3D wave and for points lying outside the domain of the source wave this command will return NaN. That's why in the end my 3D wave will contain some NaN elements. However, yesterday I noticed that with my source wave for triangulate3D (I need the output from this command to run the subsequent interpolate3D) being very large (2050401 rows and 4 cols), the execution time exceeded 24 hours until I aborted it before finish. I see someone mentioning MultiThread, looks like some parallel computation related term. Will it help speeding up triangulate3D?


It is not practical to use triangulate3D operation for very large data sets.

In your case, I think you should think of other ways to do your work. Say, pay attention to the speciality of your data and find a spcial method just suited to your need!
The triangulation process is O(N^2) so you are really looking at a very long computation. Depending on your application you might consider reducing the amount of data that is being triangulated, grouping parts of the data, triangulating and interpolating in smaller groups and similar approaches where you simply reduce the size of N.