Wave Indexing

Hi,

I know that it is possible to do the following given that TestWave is a 3 rows by 2 columns wave:
TestWave[0] = 100 (sets all elements of the first row to 100)
TestWave[0] = {100,200,300} (sets first row, first column to be 100, second row, first column to be 200, and third row, first column to be 300)

However, I have not found a way to declare an entire row at a time, such as if I want to declare the first row to be 100, 200, 300. The only way to do that seems to be TestWave[0][0] = 100; TestWave[0][1] = 200; TestWave[0][2] = 300. This method becomes unrealistic when TestWave has more columns. Is there syntax in Igor Pro that allows you to do the same thing without having to declare each element separately?

Thank you.
Try something along the lines of:
 
TestWave[0][] = 100 + q*100
 



See the "Waveform Arithmetic and Assignment" help topic.

--Jim Prouty
Software Engineer, WaveMetrics, Inc.
Ken wrote:
... Is there syntax in Igor Pro that allows you to do the same thing without having to declare each element separately?


You should read up about p, q, and r as index values in multi-dimensional waves. Then, play with this example via a line-by-line execution at the command line.

make/n=(3,5) testwave; edit testwave
testwave[][] = (p+1)*100
testwave = 0
testwave[][] = (q+1)*100
testwave = 0
testwave[0][] = (p+1)*100
testwave = 0
testwave[0][] = (q+1)*100
testwave = 0
testwave[][0] = (p+1)*100
testwave = 0
testwave[][0] = (q+1)*100


--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAHuntsville
Use [] when you want to set all rows or all columns of a matrix:
Make/O/N=(5,3) mat = NaN
mat[][0] = 55 // Set all rows, column zero
mat[0][] = 33 // Set row 0, all columns


Think of [] as meaning "all" of the dimension corresponding to its position in the destination expression (e.g., "all rows" or "all columns").
I'm trying to address a subsection of a larger matrix and define the values using another smaller matrix.

The function below works but throws an error ("While executing a wave read, the following error occurred: Index out of range for wave 'subSection'".)

function testSubMatrix()
    make/o/n=(10,10,100) subSection = 1
    make/o/n=(100,100,100) bigMatrix = 0
   
    bigMatrix[20,29][20,29][] = subSection[p][q][r]
end



Try,

function testSubMatrix()
    make/o/n=(10,10,100) subSection = 1
    make/o/n=(100,100,100) bigMatrix = 0
 
    bigMatrix[20,29][20,29][] = subSection[p-20][q-20][r]
end


Regards,
Kurt