---
name: "Mat_Close"
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_Close"
---

# Mat\_Close(3)

Closes an open MATLAB MAT file.

## NAME

**Mat\_Close** – Closes an open MATLAB MAT file.

## SYNOPSIS

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

*int*\

**Mat\_Close**(*mat\_t \*matfp*);

## DESCRIPTION

The **Mat\_Close**() function closes a MATLAB MAT file opened with **Mat\_Open**() or created with **Mat\_CreateVer**().

## RETURN VALUES

The function returns 0 on success. Otherwise, an error value is returned.

## EXAMPLES

```
#include "matio.h"
int main(int argc, char **argv)
{
    mat_t *matfp;
    matfp = Mat_Open(argv[1], MAT_ACC_RDONLY);
    if ( NULL == matfp ) {
        fprintf(stderr, "Error opening MAT file %s0, argv[1]);
        return EXIT_FAILURE;
    }
    Mat_Close(matfp);
    return EXIT_SUCCESS;
}
```

## SEE ALSO

[Mat\_Open(3)](/Mat_Open/3.md), [Mat\_CreateVer(3)](/Mat_CreateVer/3.md)
