cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
mostarr
Level IV

Invalid Matrix Token

Hi. I didn't find anything about this beside <https://community.jmp.com/t5/Discussions/invalid-matrix-token/td-p/2111> (a terribly formatted post) and nothing in the Scripting Index. What is an "invalid matrix token" error? What does it mean?

 

When I try to instantiate a matrix in my script like

m = [i j];

where <i> and <j> are numerical variables, it throws the error and points at i.

 

I think that's all the context I can give. Let me know if any clarification specifically is in order, I can try to help you help me.

 

Cheers,

Mike

3 ACCEPTED SOLUTIONS

Accepted Solutions
jthi
Super User

Re: Invalid Matrix Token

Cannot exactly explain the error message. Most likely related to this Construct Matrices and in the end:

Construct Matrices from Expressions

To construct matrices from expressions, use Matrix(). Elements must be expressions that resolve to numbers.

 

Names Default To Here(1);
i = 1;
k = 1;
m = Matrix({{i, k}}); //[1 1]

 

 

-Jarmo

View solution in original post

jthi
Super User

Re: Invalid Matrix Token

Play around with this example:

Names Default To Here(1);
i = 1;
k = 1;
m1 = Matrix({{i, k}}); //(1x2)
m2 = Matrix({{i}, {k}}); //(2x1)
Show(m1, m2);

and check the Construct Matrices From Lists from the link I provided earlier.

 

-Jarmo

View solution in original post

gzmorgan0
Super User (Alumni)

Re: Invalid Matrix Token

Hi there,

 

@jthi provided an answer with hard to find syntax.  I am adding on a bit as an FYI. Being a senior citizen, I still like the concept of allocating space for matrix stoage and releasing unused. It saves the need to concatenate, and might be a time savings especially for potentially large matrices.

 

Also, I think a simple method to create matrices is to use JMP's J function, it is listed in the Scripting Index > Functions > Matrix.

 

Below is a simple script demonstrating its use.  FYI. 

Names Default To Here( 1 );

m1x2 = J( 1, 2, 0 );         // a 1x2 matrix of zeros 
m2x1 = J( 2, 1, Empty() );   // a 2x1 matrix all empty values

Show( m1x2, m2x1 );

imax = 100;
jmax = 1000;

//like an ALLOCATE or DIM
mm = J( imax, jmax, Empty() );

//within the program logic and counting say imax = 5 and jmax =3;
imax = 5;
jmax = 3;

//like a redimension 
mm = mm[1 :: imax, 1 :: jmax];

Show( mm, N Col( mm ), N Row( mm ) );

 

View solution in original post

7 REPLIES 7
jthi
Super User

Re: Invalid Matrix Token

Cannot exactly explain the error message. Most likely related to this Construct Matrices and in the end:

Construct Matrices from Expressions

To construct matrices from expressions, use Matrix(). Elements must be expressions that resolve to numbers.

 

Names Default To Here(1);
i = 1;
k = 1;
m = Matrix({{i, k}}); //[1 1]

 

 

-Jarmo
mostarr
Level IV

Re: Invalid Matrix Token

Thanks, @jthi. That works!

 

Can you comment briefly on dimensionality? I think I figured it out, {{}{}} is a 2x0, but I don't know how to make a 0x2.

 

Mike

jthi
Super User

Re: Invalid Matrix Token

Play around with this example:

Names Default To Here(1);
i = 1;
k = 1;
m1 = Matrix({{i, k}}); //(1x2)
m2 = Matrix({{i}, {k}}); //(2x1)
Show(m1, m2);

and check the Construct Matrices From Lists from the link I provided earlier.

 

-Jarmo
mostarr
Level IV

Re: Invalid Matrix Token

Okay will do, sorry about the unneccesary post down there, didn't see your response here. Thank you greatly!
mostarr
Level IV

Re: Invalid Matrix Token

I am having trouble concatenating using Concat() or |/ my starting array and additional elements. When I Write() the output, it is equivalent to the starting array, nothing was concatenated (result is [0 0]).
jthi
Super User

Re: Invalid Matrix Token

For Matrix Concatenation JMP Help will most likely have the answers JMP Help - Matrix Concatenation

 

Also remember to set the value to old matrix if you want to change the value

Names Default To Here(1);
i = 1;
k = 1;
m1 = Matrix({{i, k}}); //(1x2)
Write(m1);
Write("\!N");
m1 |/= [2 2]; //or m1 = m1 |/ [2 2]; or m1 = VConcat(m1, [2 2]);
Write(m1);
-Jarmo
gzmorgan0
Super User (Alumni)

Re: Invalid Matrix Token

Hi there,

 

@jthi provided an answer with hard to find syntax.  I am adding on a bit as an FYI. Being a senior citizen, I still like the concept of allocating space for matrix stoage and releasing unused. It saves the need to concatenate, and might be a time savings especially for potentially large matrices.

 

Also, I think a simple method to create matrices is to use JMP's J function, it is listed in the Scripting Index > Functions > Matrix.

 

Below is a simple script demonstrating its use.  FYI. 

Names Default To Here( 1 );

m1x2 = J( 1, 2, 0 );         // a 1x2 matrix of zeros 
m2x1 = J( 2, 1, Empty() );   // a 2x1 matrix all empty values

Show( m1x2, m2x1 );

imax = 100;
jmax = 1000;

//like an ALLOCATE or DIM
mm = J( imax, jmax, Empty() );

//within the program logic and counting say imax = 5 and jmax =3;
imax = 5;
jmax = 3;

//like a redimension 
mm = mm[1 :: imax, 1 :: jmax];

Show( mm, N Col( mm ), N Row( mm ) );