The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 LabTalk Forum
 simple example for the mathematica link?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

gyne

Germany
1 Posts

Posted - 06/19/2002 :  02:29:09 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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.


Go to Top of Page

gyne

Germany
1 Posts

Posted - 06/19/2002 :  7:10:47 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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 ; )
Go to Top of Page

gyne

Germany
1 Posts

Posted - 06/19/2002 :  7:11:03 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

gyne

Germany
1 Posts

Posted - 06/19/2002 :  7:11:18 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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.
Go to Top of Page

gyne

Germany
1 Posts

Posted - 06/19/2002 :  7:11:33 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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.
Go to Top of Page

gyne

Germany
1 Posts

Posted - 06/19/2002 :  7:11:51 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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?
Go to Top of Page

gyne

Germany
1 Posts

Posted - 06/19/2002 :  7:14:00 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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 ; )
Go to Top of Page

gyne

Germany
1 Posts

Posted - 06/19/2002 :  7:14:42 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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 ; )
Go to Top of Page

gyne

Germany
1 Posts

Posted - 06/19/2002 :  7:14:58 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply



Edited by - gyne on 06/19/2002 19:22:23
Go to Top of Page

gyne

Germany
1 Posts

Posted - 06/19/2002 :  7:15:55 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply




Edited by - gyne on 06/19/2002 19:21:17
Go to Top of Page

gyne

Germany
1 Posts

Posted - 06/19/2002 :  7:16:07 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply

Go to Top of Page

cpyang

USA
1406 Posts

Posted - 06/19/2002 :  11:24:36 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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


Go to Top of Page

eparent

118 Posts

Posted - 06/20/2002 :  08:31:44 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000