HyperMath

Importing and Exporting MATLAB Binary Data (.mat)

Importing and Exporting MATLAB Binary Data (.mat)

Previous topic Next topic Expand/collapse all hidden text  

Importing and Exporting MATLAB Binary Data (.mat)

Previous topic Next topic JavaScript is required for expanding text JavaScript is required for the print function  

Certain MATLAB binary data types are supported in HyperMath. These include:

Numeric scalar, vectors and matrix.  A MATLAB scalar is converted to HyperMath vector of one element and a HyperMath scalar is converted to a MATLAB vector of single element.
String.
Structures (including array of structures) containing any of the above and other structures.  MATLAB structures are converted to HyperMath tables and vice versa.
hmtoggle_plus1R = ImportMatFile(filename)

Imports a MATLAB binary file (version 5 or lower) and creates the corresponding variables in HyperMath.  Unsupported data types are ignored.

Option

Description

filename

A string containing the Matlab data filename with full path. Use forward slash (/) or (\\) for folder separators.

R

A Boolean indicating the status of the operation. A true is returned on success.

hmtoggle_plus1R = ExportMatFile(filename, var1, …, varN)

Exports a set of HyperMath variables of any of the above supported types to its corresponding MATLAB binary format in the specified file. Any existing file is overwritten.

Option

Description

filename

A string containing the Matlab data filename with full path. Use forward slash (/) or (\\) for folder separators.

var1,…, varN

A set of strings containing the names of the HyperMath variables to be exported.

R

A Boolean indicating the status of the operation. A true is returned on success.

hmtoggle_plus1Example

This example shows how to export a two-element array of HyperMath structures, each containing a string and a vector, to the Matlab binary format.

DataArray = {} // This will be exported

// Size the array & insert contents

DataArray[1]={}

DataArray[2]={}

DataArray[1].Name = "Vector 1"

DataArray[1].Vector = [1:10]

DataArray[2].Name = "Vector 2"

DataArray[2].Vector = [1:10]

ExportMatFile("c:/test.mat", "DataArray");