Editing single point in matrix
| awirsing | March 1, 2012 - 02:48 | ||
|---|---|---|---|
|
|
|||
| thomas_braun | March 1, 2012 - 02:50 | ||
|---|---|---|---|
|
|
|||
| ChrLie | March 1, 2012 - 03:03 | ||
|---|---|---|---|
|
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) But as already pointed out, your task can be done with a one-liner. |
|||
| Jonpope | March 1, 2012 - 04:12 | ||
|---|---|---|---|
|
|
|||
| Thomas.Dane | March 1, 2012 - 04:33 | ||
|---|---|---|---|
|
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 Thanks |
|||
| s.r.chinn | March 1, 2012 - 04:59 | ||
|---|---|---|---|
|
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. |
|||
| March 1, 2012 - 10:00 | |||
|---|---|---|---|
|
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. |
|||


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.
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