---
name: "Mat_CreateVer"
section: "3"
platform: "linux"
package: "libmatio"
version: "1.5.30-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/Mat_CreateVer"
---

# Mat\_CreateVer(3)

Creates a MATLAB MAT file.

## NAME

**Mat\_CreateVer**, **Mat\_Create** – Creates a MATLAB MAT file.

## SYNOPSIS

**#include \<matio.h\>**

*mat\_t* *\**\

**Mat\_CreateVer**(*const char \*matname*, *const char \*hdr\_str*, *enum mat\_ft mat\_file\_ver*);

*mat\_t* *\**\

**Mat\_Create**(*const char \*matname*, *const char \*hdr\_str*);

## DESCRIPTION

The **Mat\_CreateVer**() function creates a MATLAB MAT file opened for write access. The *hdr\_str* is a string written in the file header of MAT version 5 and 7.3 (HDF) files. Only the first 128 bytes of the string is written. If *hdr\_str* is NULL, then a default string is written that contains the platform, date, matio library version.

The *mat\_file\_ver* argument specifies the MAT file version to create. The matio library can write version 4 files (MAT\_FT\_MAT4), version 5 files (MAT\_FT\_MAT5), and an HDF5 file format introduced in MATLAB version 7.3 (MAT\_FT\_MAT73).

The **Mat\_Create**() function is equivalent to calling **Mat\_CreateVer**() with MAT\_FT\_DEFAULT as the file version.

## EXAMPLES

```
#include <stdlib.h>
#include <stdio.h>
#include "matio.h"
int main(int argc, char **argv)
{
    mat_t *matfp;
    matfp = Mat_CreateVer(argv[1], NULL, MAT_FT_73);
    if ( NULL == matfp ) {
        fprintf(stderr, "Error creating MAT file %s0, argv[1]);
        return EXIT_FAILURE;
    }
    Mat_Close(matfp);
    return EXIT_SUCCESS;
}
```

## SEE ALSO

[Mat\_CreateVer(3)](/Mat_CreateVer/3.md), [Mat\_Close(3)](/Mat_Close/3.md)
