cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Submit your abstract to the call for content for Discovery Summit Americas by April 23. Selected abstracts will be presented at Discovery Summit, Oct. 21- 24.
Discovery is online this week, April 16 and 18. Join us for these exciting interactive sessions.
Choose Language Hide Translation Bar
h_lazar
Level I

dynamically define a matrix

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 (Alumni) ms
Super User (Alumni)

Re: dynamically define a matrix

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

ld_targets = matrix(3, i_ncols);

View solution in original post

2 REPLIES 2
ms
Super User (Alumni) ms
Super User (Alumni)

Re: dynamically define a matrix

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

ld_targets = matrix(3, i_ncols);

h_lazar
Level I

Re: dynamically define a matrix

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