Origin has made two major improvements in recent versions regarding MATLAB support.
First is on communication between Origin and a running instance of MATLAB. This way the data generated in current MATLAB can now be conveniently passed into Origin for graphing or further analysis. In the past, Origin could only communicate to new instance of Matlab. Variables in existing Matlab could not be detected.
Second, we improved MATLAB Data Connector that MATLAB data format with complex hierarchical structure can be properly handled in Origin. We also introduced Data Navigator and Data Slider panel which helps to browse dataset with many variables.
MATLAB console improvement to connect to running session of MATLAB
Launch Origin and MATLAB first. This example will connect Origin to the running MATLAB session, pass some data from Origin to MATLAB, run analysis in MATLAB, then pass the result back to Origin.
1. Open the opju file in the attached zip file in Origin. Open the first folder containing a worksheet and a graph. Select from menu Connectivity:MATLAB Console... Click the Copy Command button.
2. Goto MATLAB and paste to the command line window and press Enter to run.
3. Go back to Origin and hit the Retry button. The connection should be created and MATLAB console in Origin is popped up.
4. The message at the top of the MATLAB Console window tells two methods to transfer data between Origin and MATLAB. We can either use Export/Import button (see figure below) or use command (next step). The advantage of using command is that you can specify which column to get and put data. We will see in next step. Detailed command syntax can be found in the following page:
5. Make sure the worksheet is activated. Then run the command line below:
pwr col(2) y1
y2 = smoothdata(y1,'gaussian',200);
gwr col(3) y2
The data in Col(2) is passed to MATLAB as variable y1. it is then smoothed using MATLAB function smoothdata and the smoothed variable y2 is then transferred back to Origin and saved in Col(3) of the worksheet.
6. Check the graph where the smoothed curve is added.
This improvement is beneficial to MATLAB programmers who often get a lot of results in MATLAB. To examine the results in Origin, e.g. graphing, he just needs to launch Origin, connect to existing MATLAB session and pass these variables to Origin. This is not possible in the past that Origin can only open a new MATLAB session and have to relocate the results into the session to transfer.
Improvements for MATLAB Data Connector
1. Create a new worksheet. Select from menu Data:Connect to File:MATLAB…. Select AnalogData.mat under Data subfolder. Data Connector Browser is popped up and shows the hierarchical structure of the data. Double click the Time array to add it to lower panel. Click OK button to import.
2. A data navigator panel is added to the left of the worksheet and user can easily browse the content of the data file. it can be closed or hided with buttons at the top. If it is closed, click the green Data Connector icon and show data navigator again.
3. Right click on a single variable or a node containing multiple variables in the data navigator. In the context menu, you can add the data to current sheet or new sheet. Let’s right click on EMG node, and select Add to Active Sheet. Data from all channels under the node is appended to the current sheet.
4. Let’s check another improvement with MATLAB image import. Create a new matrix workbook, drag and drop IMG18v73.mat into Origin. This .mat file contains image variables are now displayed as image view in Origin matrix. Data navigator can still be used to check individual images. Besides that, a data slider is added on the top which helps navigating images more easily. Click the picture below to show the animation.
5. Please also check the project in the zip file. Go to the second folder. Click the data connector icon and click import to check the result.