cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Learn how to build custom Python data connectors and further customize JMP’s Data Connector Framework with the Python Data Connector Demo, available now in the JMP Marketplace!
  • See how to create experiments to support product design and ID useful product features. Register for June 12 webinar, 2pm US Eastern Time.

Discussions

Solve problems, and share tips and tricks with other JMP users.
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

Recommended Articles