## Dynamically naming and exporting MAT files

I've tried to search stackoverflow for a solution, but the cases I found differ slightly from what I'm trying to do, so I thought I'd ask.

I have a loop in MATLAB, which for every iteration, a large matrix is computed. I want to save each matrix as a separate MAT file, however each file needs to be named according to its position in loop. For example: matrix1, matrix2,...

The method I'm using to save my data (which seemed different from the few examples I found) is the following (where matrix is the generated matrix and matrix1 is the filename to be saved for the matrix corresponding to i = 1)

```
save matrix1 matrix;
```

I've seen something similar to

```
save ['matrix', i] matrix;
```

But I can't seem to remember the exact syntax.

Sorry if the question is very basic, a simple nod in the right direction for this type of saving would be greatly appreciated.

Show source

## Answers to Dynamically naming and exporting MAT files ( 2 )

Here's my nod:

Good luck! :)

Use the functional form of

`save`

: