Example array submission script
In this case, an array of 10 jobs with ids from 1 to 10 are created. All jobs share them same Slurm job id ($SLURM_JOB_ID), but have task ids that match their array value ($SLURM_ARRAY_TASK_ID). The variable a is assigned to the value of the array task id before being passed into the MATLAB script. The output files are set up to use both the job id and array task id in the filename to avoid being overwritten by other jobs/tasks.
The --array line configures the number and value of the tasks. There are many ways to configure this command - see the Slurm job array command reference for more information.