Subscribe Bookmark RSS Feed

invalid matrix token

h_lazar

Community Trekker

Joined:

Jun 23, 2011

Can someone tell me what the error "invalid matrix token" means? I am using the following script in a for loop (j as iterator) in order to graph and add a box for limits. However, the script is giving me the matrix error. Can someone give me a hint?

dgb=Bivariate(
Y(Column(yPlot)),
X(Column(xPlot)),
SendToReport(
Dispatch({}, "1", ScaleBox, {Max(xmax), Min(xmin)}),
Dispatch({}, "2", ScaleBox, {Max(ymax), Min(ymin)}),
Dispatch({},"Bivar Plot",FrameBox,
Add Graphics Script(
2,
Description("Script"),
Transparency(0.5);
FillColor({0.38, 0.84, 0.67});
Polygon([xLL,xLL,xUL,xUL], [yLL,yLL,yUL,yUL]);
)
)
)
);

xLL,xLL,xUL,xUL,yLL,yLL,yUL,and yUL are matrices of numbers. It also seems that this will not put the numbers in the script to the graph. Does anyone know how to do this?

Message was edited by: h.lazar

Message was edited by: h.lazar
7 REPLIES
h_lazar

Community Trekker

Joined:

Jun 23, 2011

So I figured out I had to use substitute but this still does not place the numbers in the script for the plot. Anyone have any ideas?

db=Bivariate(
Y(Column(yPlot)),
X(Column(xPlot)),
//invisible,
SendToReport(
Dispatch({}, "1", ScaleBox, {Max(xmax), Min(xmin)}),
Dispatch({}, "2", ScaleBox, {Max(ymax), Min(ymin)}),
Dispatch({},"Bivar Plot",FrameBox,
Add Graphics Script(2,
Description("Targets and Limits"),
PenColor("black");
PenSize(2);
Eval(Substitute(Expr(Line({xt1,y11},{xt1,y22})),
expr(xt1),xT,expr(y11),yLL,expr(y22),yUL));
Eval(Substitute(Expr(Line({x11,yt1},{x22,yt1})),
expr(x11),xLL,expr(yt1),yT,expr(x22),xUL));
Transparency(0.15);
FillColor(66);
Eval(Substitute(Expr(Polygon(
matrix({x11, x11, x22, x22}),matrix({y11, y22, y22, y11}))),
expr(x11),xLL,
expr(x22),xUL
expr(y11),yLL,
expr(y22),yUL))
);
);
);
);
);
h_lazar

Community Trekker

Joined:

Jun 23, 2011

does anyone have an answer to this? how do you script and "add graphics script" to a platform graph and insert values for variables?

thanks
Heather
I've tried loading this script to try it out for myself, but there are a couple of errors in it (there's a comma missing at the end of the "expr(x22)" line plus one mismatched bracket at the end). Correcting these as I'm assuming they should be corrected gives the program below, which I've tried running on one of the supplied data sets as shown: it crashes because it doesn't know what "xT" is. I can see another reason it might not work, namely that xmax, xmin, ymax and ymin aren't defined in this data set, but since I don't have your data I don't know what values these should take:

Another thought: the problem looks as if it involves inserting numbers into the script as opposed to variable names. In such cases I usually create a block of text which contains the script I know I want to run, and then parse it.

For example, suppose I wanted to add a property called "Cutoff" to the "Height" column of Big Class, and I wanted the value of Cutoff to be whatever number is held in a variable called CutoffValue, which is currently 60. My first guess might be to do it like this:

CutoffValue = 60;
dt = open("$SAMPLE_DATA/Big Class.jmp");
column(dt, "Height") << set property(Cutoff, CutoffValue);

That doesn't work however: if you inspect the properties of the "Height" column, all you see is "CutoffValue". One way out is to use eval, as you've done several times in your script:

column(dt, "Height") << set property(Cutoff, eval(CutoffValue));

Alternatively, try setting up something like this:

TextToParse = "column(dt, \!"Height\!") << set property(Cutoff, " || char(CutoffValue) || ");";
show(TextToParse);
eval(parse(TextToParse));

The advantage of the above is that if it still isn't working, at least you can write the expression to the log to make sure you've got the syntax right. I sometimes write entire blocks of script like this when they get seriously complicated: perhaps you could do something similar with your script too.
h_lazar

Community Trekker

Joined:

Jun 23, 2011

David

Thanks for responding. This script is part of a much larger script involving importing a list of column names to plot. I will post the script here but you will not be able to test it. If you see better practices, I am all ears.

The issue is, in fact, trying to insert a value from a variable. In this case, I want to use it in "Add Graphics Script" to create a box at the limits of the columns I am plotting. I have done something similar before by using substitute and eval statements into formulas of columns. However, it is not working for this particular case. When I look at the resulting graphics script of the graph, it is printed exactly as the code is stated and the values are not substituted.

I think I finally understand eval but I am not sure I understand the parse function. Are you suggesting that the actual script string be assigned to a variable (using parse)? I can try this but my question is do I evaluate the script variable before I run the "Add Graphics Script" line or during. I am afraid that if I do it during, I will not get the result I want.

here is the script. I hope it is formatted as nicely as yours. The portion in question is currently commented out and I have used adding reference lines temporarily. I would love to get it to work as originally planned.

h_lazar

Community Trekker

Joined:

Jun 23, 2011

David, I got it to work. The key was to use the parsing thing. I had to create the script to send to the report after the graph had been created. It seems like I should be able to do it within the graph creation itself but this works for me. Thanks for your help, that little coding went a long way.

Hi Heather - that's great: I'm glad you've got it working because I don't think I'd be able to dissect the script itself! :)

David