cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
Jackie_
Level VI

Copying data from Matrix to JMP file

Hi,

 

I imported the data from the column properties into a matrix. My question is how can I copy data from matrix into JMP file?

Spec2 = Function( {co},
	a = Column( co ) << get property( "Spec limits" );
	b = a["UL"];
	C = Matrix( {b} );
);

Copying data from Variable C into JMP file

 

Any suggestion?

 

5 REPLIES 5
txnelson
Super User

Re: Copying data from Matrix to JMP file

There are many ways to move data from a matrix into a JMP Data Table.  So the method to use, is really dependent upon what/where you are going to put the matrix data in the data table.  A JMP Data Table can be dealt with as if it is just a big two dimensional matrix, several one dimensional matrices,  A Column and row, much like Excel, etc.

So in your sample, if you were moving your b matrix into a data table you could specify

dt[1,5] = b[1];
// or
Column(1)[5] = b[1];
// or
dt:mySpecs[5] = b[1];
// or
dt << New Column("mySpecs", set values(b));

I strongly suggest you read the sections in the Scripting Guide on Matrices in Chapter 7, and all of Chapter 9, which covers Data Table programming.

     Help==>JMP Documentation Library...…….Scripting Guide

Additionally, in your sample function, you seem to be pulling out the Upper Spec Limit, from the Spec Limits column property.  You are referencing it at "UL".  The List element name is "USL"

Jim
pmroz
Super User

Re: Copying data from Matrix to JMP file

Here's one way to put a 2D matrix into a table:

matr = [1 2 3, 4 5 6, 7 8 9];

nr = nrows(matr);
nc = ncols(matr);

dt = new table("Matrix Version", add rows(nr),
		new column("c1", numeric, continuous)
);

for (i = 1, i <= nc, i++,
	one_col = "c" || char(i);
	if (i > 1,
		dt << new column(one_col);
	);
	column(dt, one_col) << set values(matr[1::nc,i]);
);

Ditto on RTFM.

Craige_Hales
Super User

Re: Copying data from Matrix to JMP file

Convert Matrix to Data Table and Back is another answer to converting a matrix to a table.

Craige
pmroz
Super User

Re: Copying data from Matrix to JMP file

Thanks Craige - where has AsTable() been hiding all of my life!!??

Craige_Hales
Super User

Re: Copying data from Matrix to JMP file

It hides well:

  • Does not have "matrix" in its name, needs an alias like MatrixToDataTable.
  • Mis-categorized in the scripting index as a row function.
  • A matrix is a primitive type in JMP, not an object, so the function is not associated with an object. 

@EvanMcCorkle @XanGregg @sheila_loring @Justin_Chilton 

Craige