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!
  • Use World Cup data to build models, explore spatial relationships, and create informative visualizations in JMP. Register. July 17, 2 pm US Eastern Time.
  • Your voice matters! Tell us how you prefer to receive JMP updates, so we can tailor our communication to your needs. Take short survey.

Discussions

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

Trying to avoid Transposition

I have a script that works but applies transposition for that to happen.  Wondering if there's a less clunky way to achieve the goal?  I have 3 columns, one contains a quadratic coefficient(a), the second contains a linear coefficient(b), and the third contains a constant(c).  When multiplied by an input variable x, I get an arc.  Is there a way to form that arc without transposing the data to do so?  Presently, I create columns with incremental changes in x in a transposed table but the data is very digital and there may be a better approach.

ax² + bx + c = 0


Slán



SpannerHead
1 ACCEPTED SOLUTION

Accepted Solutions
mmarchandFSLR
Level VI

Re: Trying to avoid Transposition

Something like this should work.  I added a column called "X Limit" and put a couple numbers in there.

 

Names Default To Here( 1 );

dt = Current Data Table();

nw = New Window( "window", gb = Graph Box( X Scale( 0, 120 ), Y Scale( 0, 35000 ) ) );
For Each Row(
	dt,
	Eval(
		Eval Expr(
			gb[FrameBox( 1 )] << Add Graphics Script(
				Y Function(
					Expr( dt[Row(), "HL_HR1_R"] ) + Expr( dt[Row(), "HL_HR2_R"] ) * x + Expr( dt[Row(), "HL_HR3_R"] ) * Power( x, 2 ),
					x,
					Max( Expr( dt[Row(), "X Limit"] ) )
				)
			)
		)
	)
);

mmarchandFSLR_0-1776289266804.png

 

View solution in original post

8 REPLIES 8
txnelson
Super User

Re: Trying to avoid Transposition

Take a look at the Y Function

Jim
SpannerHead
Level VI

Re: Trying to avoid Transposition

Jim

 

Thanks for this, don't seem to be able to find a decipherable example of that.  I did suspect there was a better way to do this.  Incidentally, the upper limit of X is stored in a column also.


Slán



SpannerHead
jthi
Super User

Re: Trying to avoid Transposition

Pull values from your table to the example found from Scripting Index. Evaluate the values to the the Y Function for example with Eval(EvalExpr())

Names Default To Here(1);
New Window("Example",
	Graph Box(
		Pen Color("red");
		Y Function(20 + 40 * Sin(a / 30), a);
	)
);

Optionally you can create formula column and use Profiler

-Jarmo
SpannerHead
Level VI

Re: Trying to avoid Transposition

Tried this but I need to raise x to the power 2 and that seems to be where it fails.

 

Names Default To Here(1);

dt = Current Data Table();

nw = New Window("window", vlb = V List Box());
For Each Row(dt,
	Eval(EvalExpr(
		vlb << Append(Graph Box(Y Function(Expr(dt[Row(), "HL_HR1_R"]) + Expr(dt[Row(), "HL_HR2_R"]) * x + Expr(dt[Row(), "HL_HR3_R"]) * Power (x, 2) ,x)));
	))
);

 


Slán



SpannerHead
mmarchandFSLR
Level VI

Re: Trying to avoid Transposition

How does it fail?  Any error message?  Your code works when I run it on a dummy table with four rows.  I just might want to adjust the axes some.

 

mmarchandFSLR_0-1776288507002.png

 

SpannerHead
Level VI

Re: Trying to avoid Transposition

Error was self inflicted, you're right, it does plot.  I have 2 remaining challenges.

1 I would like all the plots on a single graph.

2 I would like to limit x for each plot to a value stored in another data column.  Generally, that value is >100.


Slán



SpannerHead
mmarchandFSLR
Level VI

Re: Trying to avoid Transposition

Something like this should work.  I added a column called "X Limit" and put a couple numbers in there.

 

Names Default To Here( 1 );

dt = Current Data Table();

nw = New Window( "window", gb = Graph Box( X Scale( 0, 120 ), Y Scale( 0, 35000 ) ) );
For Each Row(
	dt,
	Eval(
		Eval Expr(
			gb[FrameBox( 1 )] << Add Graphics Script(
				Y Function(
					Expr( dt[Row(), "HL_HR1_R"] ) + Expr( dt[Row(), "HL_HR2_R"] ) * x + Expr( dt[Row(), "HL_HR3_R"] ) * Power( x, 2 ),
					x,
					Max( Expr( dt[Row(), "X Limit"] ) )
				)
			)
		)
	)
);

mmarchandFSLR_0-1776289266804.png

 

SpannerHead
Level VI

Re: Trying to avoid Transposition

This approach works, however, it is much slower than the transposition method I was originally using.  I can have a lot of data to process unfortunately.


Slán



SpannerHead

Recommended Articles