Editing single point in matrix

Hello

Before reading on I am aware this is an extremely basic question, however after consulting the Igor Manual and this forum I've been unable to find an answer to it.

The function below is intended to read through all the data points in a matrix and change any values above 100000 (which indicates a dead pixel in the detector) to zero/NaN.
However I have been unable to find a command that can edit a single point; when doing this manually the command window displayed 'Edit Wavename.Id' which sadly is of no use in a function.

Function Removedeadpixels(thewave)
Wave thewave
variable xx, yy, zz
xx=0
do
yy=0
do
zz= thewave [xx][yy]
if(zz>=100000)
zz=0//Syntax for editing a data point?
endif
yy=yy+1
while (yy<=487)
xx=xx+1
while (xx<=195)
End

Also in it's current form would the function save the changes in the wave if it is in a string when used in other functions?

Thanks in advance
Jon
This can be done in an one-liner: thewave = thewave >= 100000 ? nan : thewave. This changes all datapoints to nan in thewave if they are equal or greater than 100000.
A
Hi Jon,

executing
DisplayHelpTopic "Multidimensional Wave Assignment"
in the command line will open the relevant help section.

For your application you can also have a look at FindLevels which is faster than homebrewn code.

In your example, you define zz which takes a value from theWave, but then in your if-statement you actually change zz, but not the point in the wave. You would need:

if (theWave[xx][yy] >= 100000)
theWave[xx][yy] = 0
endif


But as already pointed out, your task can be done with a one-liner.
awirsing wrote:
This can be done in an one-liner: thewave = thewave >= 100000 ? nan : thewave. This changes all datapoints to nan in thewave if they are equal or greater than 100000.
A


Sorry to butt in on this thread but I have seen this kind of syntax on the forum before and it seems like a nice way of doing in one line what an if loop would do. Are there any sections in the manual which describe this notation?

Thanks
Tom
I haven't looked in the Manual, but there is a more conveniently accessed Help description for ' ?: ' in the opened Igor application. In the Help Browser window, under the 'Command Help' tab, check the 'Programming' box. You will find the ' ?: ' symbol listed near the top, with the other mathematical operation symbols.
Hello Jon,

Here is one more way to accomplish the task that is probably a bit more efficient:



If you want to set something above threshold to NaN:
Variable threshold=100000
MatrixOP/O processedWave=theWave*(greater(threshold,theWave)/greater(threshold,theWave))


If you want to replace the NaNs with any particular value:
MatrixOP/O resultWave=ReplaceNaNs(inputWave,replacementValue)


I hope this helps,

A.G.
WaveMetrics, Inc.
This can be done in an one-liner: thewave = thewave >= 100000 ? nan : thewave. This changes all hgh datapoints to nan in thewave if they are equal or greater than 100000.