## Editing single point in matrix

Jonpope
Posts: 23
Joined: 2012-01-11
Location: United Kingdom

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.

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?

Jon

[ last edited April 24, 2012 - 22:43 ]
awirsing
Posts: 134
Joined: 2007-09-19
Location: Germany

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

[ last edited March 1, 2012 - 02:50 ]
thomas_braun
Posts: 95
Joined: 2009-10-07
Location: Germany

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.

ChrLie
Posts: 97
Joined: 2009-01-06
Location: Switzerland

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

Jonpope
Posts: 23
Joined: 2012-01-11
Location: United Kingdom

Thanks alot for the help. All sorted.

Thomas.Dane
Posts: 51
Joined: 2011-05-10
Location: United Kingdom

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

s.r.chinn
Posts: 176
Joined: 2007-08-16
Location: United States

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.

Posts: 347
Joined: 2007-06-29
Location: United States

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.

Samueli
Posts: 1
Joined: 2012-05-16
Location: United States

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.