25.2.6 Procedure and Examples for Using Mathematica LinkMathematica-Procedure-EX
In this page, we will talk about the procedure of using Origin's Mathematica Link, and also include examples. The version of Mathematica used here is Mathematica 10.0.
Start Mathematica Link in Origin
Before launching the tool, you will need to set up the Kernel configuration in Mathematica to link to Origin's kernel OSequencer.exe. Refer to this page for detailed steps.
Examples
Before attempting these examples, please launch the Mathematica Link in Origin using the procedure in the previous section.
Example 1
This example sends worksheet data to and receive from Methematica
- Import the data <Origin Installation Directory>/Samples/Signal Processing/fftfilter1.DAT to a new worksheet by using the system default theme, in order to make sure that the workbook name and worksheet name are renamed with the file name, fftfilter1.
- Activate the Origin Link for Mathematica dialog, and go to the Column tab. In the Send Column group, set Mathematica Variable and Orgin Dataset as raw and [fftfilter1]fftfilter1!col(b) respectively.
-
- Click the Send button to send the second column of data to Mathematica.
- Go to the Evaluate tab, type the following two lines for Input
- temp=Fourier[raw]
- realpart=Re[temp]
- Click the Evaluate button to get the results.
-
- Go to the worksheet, click the Add New Columns button in the Standard toolbar to add column C to the worksheet.
- Go back to the Origin Link for Mathematica dialog and activate the Column tab. Set the Receive Column group as:
- Mathematica Variable: realpart
- Origin Dataset: [fftfilter1]fftfilter1!col(c)
-
- Click the Receive button, and the result will be placed into column C of the worksheet.
-
Example 2
This example sends and receives matrix data to and from Mathematica.
- Open the matrix <Origin Installation Directory>/Samples/Matrix Conversion and Gridding/2D Gaussian.ogm.
- Activate the Origin Link for Mathematica dialog and go to the Matrix tab. In the Send Matrix group, set Mathematica Variable and Origin Matrix as mat and [MBook1]Data!1 respectively.
-
- Click the Send button.
- Open Mathematica if not already started.,Create a new notebook. Select from menu Evaluation: Notebook's Kernel, make sure the kernel "OSequencer" is selected.. Now the current notebook of Mathematica can communicate with Origin.
- Enter the following script
invmat = Inverse[mat] and execute it.
-
- Go back to Origin. Add a new matrix object to Data matrixsheet. Click the D icon at the top-right corner of Data matrixsheet. Select Add to add a new object.
- Activate the Origin Link for Mathematica dialog, and set the Receive Matrix group as:
- Mathematica Variable: invmat
- Origin Matrix: [MBook1]Data!2
-
- Click the Receive button, you will get the inverse of the original matrix.
-
Example 3
This example creates and plots a user function defined in Mathematica.
|