Working with a column of a 2D wave


I tried to create a 2D waves, Data, with 100 rows and 10 columns, by make/n=(100,10) Data
In my routine, I want to write to each column by passing "it" to a function, like Capture(Data[][i]), which write to a vector Data[][i]
but it doesn't seem to work this way as it does not accept [i] inside the parentheses.

Is there a way, without using a container vector Data_i, to perform the above?
I tried to create the container vector but it vastly (10 times) slow down the whole routine.

Appreciated if you can give me a hint if I was missing something.
There are a few ways to do what you are describing. You could extract the column and pass that to your function. You could make a new 1D wave in the other function and then assign that back to your 2D wave. However, I think the fastest would be to pass a variable for the column you wish to write to in the other function and tell Igor to work on that, e.g.

Function firstFunc()
    Make/O/N=(100,10) data
    Variable i
    for(i = 0; i < 10; i += 1)

Function Capture(i)
    Variable i
    WAVE/Z data
    data[][i] = i + gnoise(0.1) // whatever you want to do to the column

Depending on what you want to do to the column, you could just work in the first function rather than pass anything, i.e. if it's just as simple as this, the second function is not required.
Igor's language isn't as sophisticated as you want it to be:
Function Capture(Data, col)
    Wave Data
    Variable col

    ... do something with Data[][col]

John Weeks
WaveMetrics, Inc.
Thanks for your replies, I should have given more details in advance.

The biggest reason I was trying to do this was that, the Capture(wave) function is actually an XOP written in C.
It use the wave passed to it as a wave handle, where in the C function data is written onto the wave I give it.
That's why I could not really modify the Capture() in Igor like the mentioned (which I definitely wanted to).

My current (and extremely slow) implementation is to convert each column explicitly to 1D vector wave, write, then put it back into the 2D wave.
A possible solution (which I will have to check) is to pass the 2D wave directly to C and perform it there, but I am not sure how difficult is it to handle a 2D Igor wave in C?
Do you know if it will be a 2D array of some kinds?

I am not sure how difficult is it to handle a 2D Igor wave in C?
Do you know if it will be a 2D array of some kinds?

A 2D wave is an array in "column-major" order (see This means that all of the elements of one column are contiguous in memory, followed by all of the elements of the next column, and so on.

This is explained in Chapter 7 of the XOP Toolkit manual under "Organization of Numeric Data in Memory".