How to call individual column in a 2D wave
skyrock79
I ran into this problem that I could not modify an individual column in a 2D wave.
For example, in a 1D wave, wave0, it is very straightforward if I want to add 1 to every row of the wave, i just input wave0=wave0+1. But I could not do the same thing to an individual column in a 2D wave, yw[][], say if I want to add 1 to the column 5, it always gave me an error message, saying expected operand. The command I put in is yw[][5]=yw[][5]+1.
Anyone's seen this before?
Thanks
Dimin
The two methods below work.
yw[][5] = yw[p][5]+1
in the second line, you can see that I used p to specify the rows. This means that for each row, we are adding 1 to the value previously in that row, instead of a different one.
September 21, 2012 at 10:34 am - Permalink
It helps to be able to put a wave assignment statement into words. Here is how I think about it.
The lefthand side of a wave assignment statement determines which points in the destination wave will be set. The righthand side determines what a specific point in the destination will be set to.
[] means "all rows" or "all columns" depending on where it occurs. Therefore this:
means "set all rows, column 5, of yw to something".
[] on the righthand side would mean "all rows" or "all columns" but it makes no sense on the righthand side because Igor needs a specific value.
On the righthand side, "p" means "whatever row in the destination Igor is about to store into".
This:
means "set all rows of column 5 of yw to its current value (yw[p][5]) plus 1.
In this case, p will go from 0 to DimSize(yw,0)-1.
There is a similar internal index for columns: q. In this case q will go from 5 to 5.
This can also be written:
September 23, 2012 at 10:04 am - Permalink
Dimin
September 24, 2012 at 10:44 am - Permalink