2.7.34 impMatlab


Menu Information

Data: Import from File: Matlab(Mat)


If you do not see this file type, choose Data: Import from File: Add/Remove File Types...

File Import Add Menu.png

To add drag & drop support for a file type, see Import Filter Manager.

Brief Information

Import Matlab files

Command Line Usage

1. impMatlab fname:="c:\test.mat";

2. impMatlab fname:="c:\data.mat" options.impMode:=1;

Variables

Display
Name
Variable
Name
I/O
and
Type
Default
Value
Description
File Name fname

Input

string

fname$
Filename (s) of the file (s) to be imported.
File Info and Data Selection trfiles

Input

TreeNode

<unassigned>
This is used to show the file information. It allows to select which variable in the file to be imported.
Import Options options

Input

TreeNode

<unassigned>
This is mainly used in the dialog, for tweaking the import options. Please see the Descriptions section for details.
Output orng

Output

Range

<active>
This is used to specify the output range.

See the syntax here.

Note: Matrices can exist as standalone windows or they can be embedded in a worksheet. The impMatlab X-Function is programmed to recognize embedded matrices and to treat them as a matrix rather than as a worksheet. Thus, when the active worksheet contains an embedded matrix, impMatlab is able to output the imported data to the embedded matrix in the active workbook sheet.

Header Info trheader

Output

TreeNode

<optional>
This is for outputting the header information. It is hidden from the GUI. Users are not advised to use this variable.

Description

This X-Function is used for importing Matlab data files. You can import multiple files at one time, and variables in each file are selectable for importing. The destination and stored structure can be specified too.

In Origin, variables in each Matlab data file are stored in the following ways:

  1. In the Workbook
    • Not Hierarchical Structure: By default, all variables in each file will be stored in the same worksheet one-by-one. All will begin with the same row.
    • Hierarchical Structure: Only the variable list is imported into a worksheet, and the individual variable names are displayed as linked text in the 1st column. Clicking on variable names will import the desired variables one-by-one in the new worksheets.
  2. In the Matrixbook
    Each variable will be stored in a matrix sheet.


Details on Some Dialog Options

  • Import Options(options)
Please see this page for more details.

Examples

Example 1

This example will show you how to import a Matlab file with structure data into hierarchical structure.

  1. Create a new workbook and activate it.
  2. From the Origin main menu, select Data: Import from File: Matlab (Mat)....
  3. In the MatlabFiles dialog, browse to \Samples\Import and Export\Matdata_Struct.mat, then click the Add File(s) button. Make sure to check the Show Options Dialog checkbox and click the OK button to open the impMatlab dialog.
  4. In the dialog box, note that the Variables box under the File Info and Data Selection branch is empty. Some variables in the MATLAB file are not supported by Origin. If you import your file using default settings, these variables will be skipped.
    ImpMatlab 01.png
  5. For the structure data in the MATLAB file, check the Import into Hierarchical Structure box under the Import Options branch. Note that the File Info and Data Selection branch, Save File Info. in Workbook and Import Mode options are now grayed out.
    ImpMatlab 02.png
  6. Click the OK button. The file will be imported. Next, click on the variable names to further import just the desired variables one-by-one, into new worksheets.
    ImpMatlab 03.png

Example 2

This example will show you how to import Matlab data files to matrixbook.

  1. Create a new matrixbook and activate it.
  2. From the Origin main menu, select Data: Import from File: Matlab (Mat)....
  3. In the MatlabFiles dialog, locate to \Samples\Import and Export\ and select files GaussianData.mat and Matdata_1.mat (Press down the Ctrl key to select multiple files.), then click the Add File(s) button. Make sure to check the Show Options Dialog check-box and click the OK button to open the impMatlab dialog.
  4. In the dialog, you will find the variables of two files are listed under File Info and Data Selection branch. Choose Start New Matrixsheets as the Import Mode.
    ImpMatlab 05.png
  5. Click the OK button, the files will be imported as:
    ImpMatlab 06.png

Related X-Functions

impFile, impinfo, impFileSel