Simple reassignment of matrix rows and columns

Hi there,

I'm struggling with the correct igor syntax for assigning columns and rows of pre-existing matrices to other waves/matrices, without the need to introduce loops

For example if I create a new wave (i.e. a column) of the correct length and want to import data from a single row of a matrix (where the number of columns in the matrix is equal to the number of points in my wave), despite trying numerous ways (see below) I'm not getting so far

column_needs_filling = matrix [ required_row_num ][]
column_needs_filling = matrix [ required_row_num ][q]
column_needs_filling = matrix [ required_row_num ][0,end_point]

column_needs_filling [][1] = matrix [ required_row_num ][]
column_needs_filling [][1] = matrix [ required_row_num ][q]
column_needs_filling [][1] = matrix [ required_row_num ][0,end_point]

column_needs_filling [][] = matrix [ required_row_num ][]
column_needs_filling [][] = matrix [ required_row_num ][q]
column_needs_filling [][] = matrix [ required_row_num ][0,end_point]

column_needs_filling [p][1] = matrix [ required_row_num ][]
column_needs_filling [p][1] = matrix [ required_row_num ][]
column_needs_filling [p][1] = matrix [ required_row_num ][0,end_point]

I have had some success with using [p][q] when embedded in a bigger loop (when writing functions), but am really struggling to do so from the command line

I know this is super simple, but it's really bugging me and I can't seem to find any relevant bits on the help docs (unless someone can point me in the right direction)

Thanks in advance for the help
Quote:
column_needs_filling = matrix [ required_row_num ][q]

That's close, but since the left-hand side is a 1D wave, you need to use p:
column_needs_filling = matrix [ required_row_num ][p]

That says, "for each row in column_needs_filling, get the data point from the same-numbered column"

Those special functions p, q, r, s, x, y, z, t on the right side refer to the current point, column, layer, chunk, etc. that's being operated on on the left side.

Quote:
column_needs_filling [p][1] = matrix [ required_row_num ][]

You can't use p, q, etc. on the left side, they only have meaning on the right side as a reference to the implied loop over the wave on the left side.

Quote:
column_needs_filling [][1] = matrix [ required_row_num ][]

That is trying to fill column 1 of a 1D wave. A 1D wave has only column 0.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
johnweeks wrote:
Quote:
column_needs_filling = matrix [ required_row_num ][q]

That's close, but since the left-hand side is a 1D wave, you need to use p:
column_needs_filling = matrix [ required_row_num ][p]

That says, "for each row in column_needs_filling, get the data point from the same-numbered column"

Those special functions p, q, r, s, x, y, z, t on the right side refer to the current point, column, layer, chunk, etc. that's being operated on on the left side.

Quote:
column_needs_filling [p][1] = matrix [ required_row_num ][]

You can't use p, q, etc. on the left side, they only have meaning on the right side as a reference to the implied loop over the wave on the left side.

Quote:
column_needs_filling [][1] = matrix [ required_row_num ][]

That is trying to fill column 1 of a 1D wave. A 1D wave has only column 0.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com


Thanks a million for that, knew it was something simple, just wasn't quite getting the correct use of the special functions.

As for filling column 1, that's me being plain stupid, need to remember when programming in Igor to start at 0 not 1!

Hope this answer can go on to help others (I have found reading others q&a's online really helpful in learning languages in the past)

What about filling a row of a 2D wave on the left with another row from another 2D wave on the right? Let's say: fill a row 0 that has 11 columns of the wave on the left with a row 0 that has also 11 columns of the wave on the right? 

This and related topics are discussed in the help. Execute this for details:

DisplayHelpTopic "Multidimensional Wave Assignment"