cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Don’t miss your chance to experience Discovery Summit Europe at our best available rate! Early bird registration through 31 Oct.
  • Image to Table JMP extension imports single or batch images as data tables. Useful to extract curves from pictures or convert image data to curve data to use in analyses like Functional Data Explorer. Download and install the extension.

Discussions

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

Can a number in an array be replaced by a variable?

For example, in the drawing of JSL the following values

Color Levels([-7.28 -1.99 3.3 8.59 13.88]);

How can I write code in this form?

x1=-7.28;
x2=13.88;
Color Levels([x1 -1.99 3.3 8.59 x2]);

Thanks!

2 ACCEPTED SOLUTIONS

Accepted Solutions
ErraticAttack
Level VI

Re: Can a number in an array be replaced by a variable?

Matrices can be a little tricky, but here is what I do in that situation:

 

x1 = -7.28;
x2 = 13.88;
Color Levels( (x1 |/ [-1.99 3.3 8.59]` |/ x2)` );

This uses the matrix join operator |/ then a few transposes to make it have the correct dimensions

Jordan

View solution in original post

jules
Community Manager Community Manager

Re: Can a number in an array be replaced by a variable?

If you construct your matrix using the Matrix() function you can call in variables as arguments directly. For example:

x1=-7.28;
x2=13.88;
mat = matrix({x1,-1.99, 3.3, 8.59, x2})`
//notice the need to transpose; the syntax is easier to construct this way

Here's a more complete building the entire matrix dynamically: 

Names Default To Here( 1 );

x1=100000; x2=1000000; x3=10000000;

dt = Open( "$SAMPLE_DATA/PopAgeGroup.jmp" );
obj = dt << Bubble Plot(
	X( :"Portion 0-19"n ),
	Y( :"Portion60+"n ),
	Sizes( :Pop ),
	ID( :Country ),
	Coloring( :Pop )
);
obj << Color Levels( matrix({x1,x2,x3})` );

I hope this helps!

@jules 

View solution in original post

3 REPLIES 3
lala
Level IX

回复: Can a number in an array be replaced by a variable?

OK

2022-12-10_15-58-59.png

ErraticAttack
Level VI

Re: Can a number in an array be replaced by a variable?

Matrices can be a little tricky, but here is what I do in that situation:

 

x1 = -7.28;
x2 = 13.88;
Color Levels( (x1 |/ [-1.99 3.3 8.59]` |/ x2)` );

This uses the matrix join operator |/ then a few transposes to make it have the correct dimensions

Jordan
jules
Community Manager Community Manager

Re: Can a number in an array be replaced by a variable?

If you construct your matrix using the Matrix() function you can call in variables as arguments directly. For example:

x1=-7.28;
x2=13.88;
mat = matrix({x1,-1.99, 3.3, 8.59, x2})`
//notice the need to transpose; the syntax is easier to construct this way

Here's a more complete building the entire matrix dynamically: 

Names Default To Here( 1 );

x1=100000; x2=1000000; x3=10000000;

dt = Open( "$SAMPLE_DATA/PopAgeGroup.jmp" );
obj = dt << Bubble Plot(
	X( :"Portion 0-19"n ),
	Y( :"Portion60+"n ),
	Sizes( :Pop ),
	ID( :Country ),
	Coloring( :Pop )
);
obj << Color Levels( matrix({x1,x2,x3})` );

I hope this helps!

@jules 

Recommended Articles