Author |
Topic  |
|
gyne
Germany
1 Posts |
Posted - 06/19/2002 : 02:29:09 AM
|
hello there,
I need a simple example for a mathematica linked program. It should include a package for functions first (e.g. < My first trial was:
ml.OpenLink(); //opens matematic link ml.Evaluate.Expression$="<< package1"; // to include the package ml.Evaluate.Expression$="OriginVarPlot[{{x,testfunc[x]}},{x,0,1}]"; // my testfunction ml.RecvColumn.MathVar$="xval"; //value to recieve ml.RecvColumn.Dataset$="Data1_a";//into column data1_a ml.RecvColumn.From=0; //start with first position
but this doesn't work.. is there a syntax error in my coding?
Thanks for your help |
|
eparent
118 Posts |
Posted - 06/19/2002 : 11:15:32 AM
|
After you set the ml.Evaluate.Expression$ property you need to call the ml.Evaluate method to pass the expression to Mathematica. After Mathematica evaluates the expression then the ml.Evaluate.Results$ property will be set with Mathematica's result.
The Link for Mathematica should have come with a PDF file that doucments the properties and methods. See this file for more information.
|
 |
|
gyne
Germany
1 Posts |
Posted - 06/19/2002 : 7:10:47 PM
|
thanks eparent,
i 've tried to understand the manual before, but ... (*headacking*) .. don't understand it completely.
I adapt the given example on "evolving an expression" (side 17) into labtalk:
ml.Openlink; //link to mathematicas kernel ml.Evaluate.Expression$="eq={x''[t]+x[t]^3=Sin[t], x[0]==x'[0]==0} NDSolve[eq,x,{t,0,50}] OriginParPlot[{x[t],x'[t]}/.%,{t,0,50}]"; ml.Evaluate.Expression$=; //print out the input ml.Evaluate(); //evaluate in mathematica ker nel ml.RecvColumn.MathVar$=xval; //name of variable in mathematica ml.RecvColumn.Dataset$=data1_a;//column for output ml.RecvColumn();//recieve column
ml.CloseLink();//quit kernel
But it doesn't work, too. :-( The text in the script window says: "ml.Evaluate.Expression$=--"
Can you tell me the error in the code? Hope you have more experience in linking to mathematica. (very possible, but i've NONE ; ) |
 |
|
gyne
Germany
1 Posts |
Posted - 06/19/2002 : 7:11:03 PM
|
sorry, there was an server problem.. i try to delete the "spam" tomorrow (deleting doesn't work, too. just changing is possible. *grr*)
Edited by - gyne on 06/19/2002 19:24:41
Edited by - gyne on 06/19/2002 19:25:12 |
 |
|
gyne
Germany
1 Posts |
Posted - 06/19/2002 : 7:11:18 PM
|
thanks eparent,
i 've tried to understand the manual before, but ... (*headacking*) .. don't understand it completely.
I adapt the given example on "evolving an expression" (side 17) into labtalk:
ml.Openlink; //link to mathematicas kernel ml.Evaluate.Expression$="eq={x''[t]+x[t]^3=Sin[t], x[0]==x'[0]==0} NDSolve[eq,x,{t,0,50}] OriginParPlot[{x[t],x'[t]}/.%,{t,0,50}]"; ml.Evaluate.Expression$=; //print out the input ml.Evaluate(); //evaluate in mathematica ker nel ml.RecvColumn.MathVar$=xval; //name of variable in mathematica ml.RecvColumn.Dataset$=data1_a;//column for output ml.RecvColumn();//recieve column
ml.CloseLink();//quit kernel
But it doesn't work, too. :-( The text in the script window says: "ml.Evaluate.Expression$=--"
Can you tell me the error in the code? Hope you have more experience in linking to mathematica. |
 |
|
gyne
Germany
1 Posts |
Posted - 06/19/2002 : 7:11:33 PM
|
thanks eparent,
i 've tried to understand the manual before, but don't understand it completely.
I adapt the given example on "evolving an expression" (side 17) into labtalk:
ml.Openlink; //link to mathematicas kernel ml.Evaluate.Expression$="eq={x''[t]+x[t]^3=Sin[t], x[0]==x'[0]==0} NDSolve[eq,x,{t,0,50}] OriginParPlot[{x[t],x'[t]}/.%,{t,0,50}]"; ml.Evaluate.Expression$=; //print out the input ml.Evaluate(); //evaluate in mathematica ker nel ml.RecvColumn.MathVar$=xval; //name of variable in mathematica ml.RecvColumn.Dataset$=data1_a;//column for output ml.RecvColumn();//recieve column
ml.CloseLink();//quit kernel
But it doesn't work, too. :-( The text in the script window says: "ml.Evaluate.Expression$=--"
Can you tell me the error in the code? Hope you have more experience in linking to mathematica. |
 |
|
gyne
Germany
1 Posts |
Posted - 06/19/2002 : 7:11:51 PM
|
thanks eparent,
i 've tried to understand the manual before, but don't understand it completely.
I adapt the given example on "evolving an expression" (side 17) into labtalk:
ml.Openlink; //link to mathematicas kernel ml.Evaluate.Expression$="eq={x''[t]+x[t]^3=Sin[t], x[0]==x'[0]==0} NDSolve[eq,x,{t,0,50}] OriginParPlot[{x[t],x'[t]}/.%,{t,0,50}]"; ml.Evaluate.Expression$=; //print out the input ml.Evaluate(); //evaluate in mathematica ker nel ml.RecvColumn.MathVar$=xval; //name of variable in mathematica ml.RecvColumn.Dataset$=data1_a;//column for output ml.RecvColumn();//recieve column
ml.CloseLink();//quit kernel
But it doesn't work, too. :-( The text in the script window says: "ml.Evaluate.Expression$=--"
Can you tell me the error in the code? |
 |
|
gyne
Germany
1 Posts |
Posted - 06/19/2002 : 7:14:00 PM
|
thanks eparent,
i 've tried to understand the manual before, but ... (*headacking*) .. don't understand it completely.
I adapt the given example on "evolving an expression" (side 17) into labtalk:
ml.Openlink; //link to mathematicas kernel ml.Evaluate.Expression$="eq={x''[t]+x[t]^3=Sin[t], x[0]==x'[0]==0} NDSolve[eq,x,{t,0,50}] OriginParPlot[{x[t],x'[t]}/.%,{t,0,50}]"; ml.Evaluate.Expression$=; //print out the input ml.Evaluate(); //evaluate in mathematica kernel ml.RecvColumn.MathVar$=xval; //name of variable in mathematica ml.RecvColumn.Dataset$=data1_a; //column for output ml.RecvColumn();//recieve column
ml.CloseLink();//quit kernel
But it doesn't work, too. :-( The text in the script window says: "ml.Evaluate.Expression$=--"
Can you tell me the error in the code? Hope you have more experience in linking to mathematica. (very possible, but i've NONE ; ) |
 |
|
gyne
Germany
1 Posts |
Posted - 06/19/2002 : 7:14:42 PM
|
thanks eparent,
i 've tried to understand the manual before, but ... (*headacking*) .. don't understand it completely.
I adapt the given example on "evolving an expression" (side 17) into labtalk:
ml.Openlink; ml.Evaluate.Expression$="eq={x''[t]+x[t]^3=Sin[t], x[0]==x'[0]==0} NDSolve[eq,x,{t,0,50}] OriginParPlot[{x[t],x'[t]}/.%,{t,0,50}]"; ml.Evaluate.Expression$=; //print out the input ml.Evaluate(); ml.RecvColumn.MathVar$=xval; ml.RecvColumn.Dataset$=data1_a; ml.RecvColumn(); ml.CloseLink();
But it doesn't work, too. :-( The text in the script window says: "ml.Evaluate.Expression$=--"
Can you tell me the error in the code? Hope you have more experience in linking to mathematica. (very possible, but i've NONE ; ) |
 |
|
gyne
Germany
1 Posts |
Posted - 06/19/2002 : 7:14:58 PM
|
Edited by - gyne on 06/19/2002 19:22:23 |
 |
|
gyne
Germany
1 Posts |
Posted - 06/19/2002 : 7:15:55 PM
|
Edited by - gyne on 06/19/2002 19:21:17 |
 |
|
gyne
Germany
1 Posts |
Posted - 06/19/2002 : 7:16:07 PM
|
|
 |
|
cpyang
USA
1406 Posts |
Posted - 06/19/2002 : 11:24:36 PM
|
I have never done this before, and I think the best will be we move this capability into OriginC, so there will be much better error checking. In the mean time, maybe it is because ml.OpenLink(); //opens matematic link
that your later script it becomes ml.OpenLink;
In general, you should err = ml.OpenLink(); err=;// print out error code
so you can check the labtalk method to see if it worked as expected.
CP
|
 |
|
eparent
118 Posts |
Posted - 06/20/2002 : 08:31:44 AM
|
gyne, You must call the Evaluate method after each time you set the Expression$ property. Once you set the Expression$ property what was there before is replaced with the new expression.
So, you must call ml.Evaluate() after each ml.Evaluate.Expression$ assignment. Your original code should look like this:
ml.OpenLink(); //opens matematic link ml.Evaluate.Expression$="<< package1"; // to include the package ml.Evaluate(); // include package1 ml.Evaluate.Expression$="OriginVarPlot[{{x,testfunc[x]}},{x,0,1}]"; // my testfunction ml.Evaluate(); // evaluate testfunction ml.RecvColumn.MathVar$="xval"; //value to recieve ml.RecvColumn.Dataset$="Data1_a";//into column data1_a ml.RecvColumn.From=0; //start with first position
Edited by - eparent on 06/20/2002 08:32:46 |
 |
|
|
Topic  |
|
|
|