Create MAT-File in C or C++
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 creates
mattest.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:
matcreat
Creating file mattest.mat...
To verify the MAT-file, at the MATLAB command prompt, type:
whos -file mattest.mat
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.