Using Internal Wave Values As Means of Indexing

Hello all,

Say I have a wave, 'myWave' which looks like:

[0, 1]

280, 2

280.5, 4

281, 6

281.5, 8

...

900, 2480

901,  2482

902, 2484

Where somewhere in the data my delta changes from 0.5 to 1.

My simple goal is to retrieve the data in the 1-column by specifying that in the 0th column.

e.g. 'print myWave(900)[1]` should spit out 2482 (interpolation is fine)

I have tried `SetScale /I x, 280, 902, "", myWave' to no avail; Igor seems to really prefer its 0-DimSize indexing.

How can I use the internal data as my accessing index?

One way to find the change in step is to calculate a forward derivative and the do a findlevel. The derivative wave on your column zero should 0.5 unit; it jumps to 1.0.  Do a find level for 1.0 or perhaps a touch less to handle rounding errors if your data is not completely exact on the 0.5 step and 1.0 step

 

Andy

Yes, wave scaling uses a constant delta, so it won't help you.

If your X column could be a separate wave, you can find the point number corresponding to a value using BinarySearch() or BinarySearchInterp(). Something like

Variable yval = ywave[BinarySearchInterp(xwave, xvalue)]

But you need to be careful- the way I've written it, if xvalue is outside the range of values, BinarySearch will return -1, or -2 depending on what direction it is out of range. To make it safe, you need more lines :)