OriginLab Corporation - Data Analysis and Graphing Software - 2D graphs, 3D graphs, Contour Plots, Statistical Charts, Data Exploration, Statistics, Curve Fitting, Signal Processing, and Peak Analysis     
 
Skip Navigation Links
All BooksExpand All Books
Origin HelpExpand Origin Help
Communicating with Other ApplicationsExpand Communicating with Other Applications
MATLAB ConsoleExpand MATLAB Console

23.3 MATLAB Console

Video Image.png See more related video:Importing and Connecting with MATLAB

The "MATLAB Console" tool allows Origin users to issue MATLAB commands from within the Origin environment, and transfer data between the two applications either using a graphical interface, or by issuing commands.

This tool requires both Origin and MATLAB be installed on the same computer.

Note that Origin also supports importing MATLAB (MAT) files from disk and this functionality is accessible from the File : Import menu. Importing MAT files does not require MATLAB to be installed.

To start the MATLAB console tool, select Tools:MATLAB Console from the Origin menu. This will launch a new instance of the MATLAB application, and the console window will open in the Origin workspace.

MATLAB Console.png

The Import Button

The Import button in the top right corner of this dialog brings up the MATLAB Import Dialog. This dialog lists all variables in the current MATLAB workspace. You can select a single variable, or use SHIFT + select to select multiple variables, and import them into Origin. Note that when importing, you can either bring the data into a worksheet, or into a matrix. Check box options allow you to update existing Origin matrices, and to add imported data to existing Origin worksheets.

The Export Button

The Export button in the top right corner of this dialog brings up the MATLAB Export Dialog. This dialog lists all variables in the current Origin project. User can assign a name for the variable in MATLAB using the Name column, then select desired Origin worksheet columns or matrices, and transfer the selected Origin data to MATLAB.

Console Commands

In addition to using the import and export dialogs to interactively transfer data between the two applications, Origin also provides a set of commands that can be typed in the console window to perform data transfer. The following table lists available commands:

Command Syntax

Description

gr matName1 matName2 ...

Get real matrices named matName1, matName2, etc. from MATLAB.

New matrix windows of the same name are created in Origin. Existing windows of the same name are overwritten.

gc matName1 matName2...

Get complex matrices named matName1, matName2, etc. from MATLAB. New matrix windows, for real and complex components, are created in Origin. Existing windows of the same name are overwritten.

pr matName1 matName2...

Put real matrices named matName1, matName2 etc. from Origin to MATLAB. Existing windows of the same name are overwritten.

pc matName1 matName2

Put complex matrices named matName1, matName2 etc. from Origin to MATLAB. Existing windows of the same name are overwritten.

pwr wkbkrange marray

Transfer real data from Origin workbook range wkbkrange, to MATLAB array named marray.

Note that wkbkrange should be a valid Origin range such as col(index), [book1]sheet1!col(name) etc.

pwc wkbkrange marray

Transfer complex data from Origin workbook range wkbkrange, to MATLAB array named marray.

Note that wkbkrange should be a valid Origin range such as col(index), [book1]sheet1!col(name) etc.

pws wkbkrange marray

Transfer strings from Origin workbook range wkbkrange, to MATLAB array named marray.

Note that wkbkrange should be a valid Origin range such as col(index), [book1]sheet1!col(name) etc.

gwkspace

gwkspace m

Get all MATLAB variables and place them in multiple matrix sheets and objects in a new matrix window in Origin

gwkspace w

Get all MATLAB variables and place them in multiple worksheets sheets in a new workbook window in Origin

Note 2: The \Samples\COM Server and Client\MATLAB subfolder contains an example (CreatePlotInOrigin.m, CreatePlotInOrigin.OPJ) that illustrates how to connect to an Origin COM server from a MATLAB client (requires MATLAB).

 

© OriginLab Corporation. All rights reserved.