Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- dynamically define a matrix

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Dec 11, 2013 9:39 AM
(765 views)

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Solution

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

ld_targets = matrix**(****3**, i_ncols**)**;

2 REPLIES

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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

ld_targets = matrix**(****3**, i_ncols**)**;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Dec 12, 2013 7:51 AM
(525 views)

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