cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • New to JMP? Join us Sept. 23-24 for the Early User Edition of Discovery Summit, tailor-made for new users. Register now for free!
  • Your voice matters! Tell us how you prefer to receive JMP updates, so we can tailor our communication to your needs. Take short survey.
  • See how to access JMP Marketplace - and - find, create & share add-ins to extend your JMP. Watch video.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
lala
Level IX

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

Recommended Articles