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
lala
Level VIII

How to concatenate identical matrices in memory?

Hello!

 

For example, how to concatenate the two matrices:

mat1=[1.05 0.17 1.64 ., 2.06 0.81 0.63 ., 0.23 1.87 1.24 -8, 0.72 0.42 0.43 -8, 0.59 0.17 0.67 -8];

mat2=[2.78 0 0.59 -8, 1.85 . 1.24 -8, 1.19 0.86 0.75 8]
1 ACCEPTED SOLUTION

Accepted Solutions
Craige_Hales
Super User

Re: How to concatenate identical matrices in memory?

You'll use the vertical concatenation operator since they have the same number of columns.

mat1 = [1.05 0.17 1.64 .,
2.06 0.81 0.63 .,
0.23 1.87 1.24 -8,
0.72 0.42 0.43 -8,
0.59 0.17 0.67 -8];

mat2 = [2.78 0 0.59 -8,
1.85 . 1.24 -8,
1.19 0.86 0.75 8];

result = mat1 |/ mat2;

show( mat1, mat2, result );

/*
mat1 = 
[	1.05 0.17 1.64 ., 
	2.06 0.81 0.63 ., 
	0.23 1.87 1.24 -8, 
	0.72 0.42 0.43 -8, 
	0.59 0.17 0.67 -8];
mat2 = 
[	2.78 0 0.59 -8, 
	1.85 . 1.24 -8, 
	1.19 0.86 0.75 8];
result = 
[	1.05 0.17 1.64 ., 
	2.06 0.81 0.63 ., 
	0.23 1.87 1.24 -8, 
	0.72 0.42 0.43 -8, 
	0.59 0.17 0.67 -8, 
	2.78 0 0.59 -8, 
	1.85 . 1.24 -8, 
	1.19 0.86 0.75 8];
*/

|/ is vertical, || is horizontal, but you have different number of rows, so horizontal will not work.

Craige

View solution in original post

1 REPLY 1
Craige_Hales
Super User

Re: How to concatenate identical matrices in memory?

You'll use the vertical concatenation operator since they have the same number of columns.

mat1 = [1.05 0.17 1.64 .,
2.06 0.81 0.63 .,
0.23 1.87 1.24 -8,
0.72 0.42 0.43 -8,
0.59 0.17 0.67 -8];

mat2 = [2.78 0 0.59 -8,
1.85 . 1.24 -8,
1.19 0.86 0.75 8];

result = mat1 |/ mat2;

show( mat1, mat2, result );

/*
mat1 = 
[	1.05 0.17 1.64 ., 
	2.06 0.81 0.63 ., 
	0.23 1.87 1.24 -8, 
	0.72 0.42 0.43 -8, 
	0.59 0.17 0.67 -8];
mat2 = 
[	2.78 0 0.59 -8, 
	1.85 . 1.24 -8, 
	1.19 0.86 0.75 8];
result = 
[	1.05 0.17 1.64 ., 
	2.06 0.81 0.63 ., 
	0.23 1.87 1.24 -8, 
	0.72 0.42 0.43 -8, 
	0.59 0.17 0.67 -8, 
	2.78 0 0.59 -8, 
	1.85 . 1.24 -8, 
	1.19 0.86 0.75 8];
*/

|/ is vertical, || is horizontal, but you have different number of rows, so horizontal will not work.

Craige