Subscribe Bookmark RSS Feed

dynamically define a matrix

h_lazar

Community Trekker

Joined:

Jun 23, 2011

I am using JSL to stack some data. The columns have Spec Limit properties so I am using JSL to manually stack those values in a matrix to add to the data as well. The problem is I can not seem to assign values to a matrix without defining it. And I can not dynamically define a matrix. Perhaps I am missing something or there are other matrix tricks someone can suggest.

dt0 is the table from which I am operating

i_ncols is determined from the number of rows in another table.

ls_colnames is the list of column names that I want to stack and is generated using another table

ld_targets is the final matrix I wish to generate with this loop

//get targets from column properties

ld_targets = [](3, i_ncols);

For( i = 1, i <= i_ncols, i++,

  For( j = 0, j <= 2, j++,

  ld_specs = Column( dt0, ls_colnames[i_ncols * j + i] ) << Get Property( "Spec Limits" );

  ld_targets[j + 1, i] = ld_specs["Target"];

  )

);

this results in a compile error "expected integer for number of columns" and will not even run.

if I do not define the matrix (comment out the first line) I get the runtime error "Nothing to set in access or evaluation of 'Assign' , ld_targets[j + 1, i] = ld_specs["Target"]"

Any suggestions?

thanks in advance

Heather

1 ACCEPTED SOLUTION

Accepted Solutions
ms

Super User

Joined:

Jun 23, 2011

Solution

Use Matrix() instead of [ ] when defining a matrix with a variable.

ld_targets = matrix(3, i_ncols);

2 REPLIES
ms

Super User

Joined:

Jun 23, 2011

Solution

Use Matrix() instead of [ ] when defining a matrix with a variable.

ld_targets = matrix(3, i_ncols);

h_lazar

Community Trekker

Joined:

Jun 23, 2011

Wow, that was really easy. Why isn't this more clear in the Scripting Guide?

Now I have to figure out how to put this matrix in a table. Look for a new post on that question.

H