Create MAT-File in C or C++ - MATLAB & Simulink (original) (raw)

Main Content

Create MAT-File in C

The matcreat.c example illustrates how to use the library routines to create a MAT-file that you can load into the MATLABĀ® workspace. The program also demonstrates how to check the return values of MAT-file function calls for read or write failures. To see the code, open the file in MATLAB Editor.

After building the program, run the application. This program createsmattest.mat, a MAT-file that you can load into MATLAB. To run the application, depending on your platform, either double-click its icon or enter matcreat at the system prompt:

Creating file mattest.mat...

To verify the MAT-file, at the MATLAB command prompt, type:

Name Size Bytes Class

GlobalDouble 3x3 72 double array (global) LocalDouble 3x3 72 double array LocalString 1x43 86 char array

Grand total is 61 elements using 230 bytes

Create MAT-File in C++

The C++ version of matcreat.c is matcreat.cpp.Open the file in MATLAB Editor.

See Also

Topics