Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions running_matlab_jobs.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ https://www.mathworks.com/products/matlab.html

To view available MATLAB versions on a CARC system, run:

```bash id="m1q8aa"
```bash
module avail matlab
```

Expand All @@ -36,7 +36,7 @@ Suppose you have a MATLAB script named `my_program.m` that generates a 3×3 matr

Example:

```matlab id="k8x2cn"
```matlab
% Generate a random 3x3 matrix
rmatrix = rand(3);

Expand All @@ -57,13 +57,13 @@ Save this file in your home directory.

If you want to test interactively, first request a compute node:

```bash id="q7v1sp"
```bash
srun --pty bash
```

Once on the compute node:

```bash id="p0d8xy"
```bash
module load matlab
matlab -batch "my_program"
```
Expand All @@ -76,11 +76,11 @@ This ensures MATLAB runs on a compute node, not the login node.

Rather than requesting an interactive shell first, you can launch MATLAB on a compute node directly from the login node with a single command. Load the module in your login shell first — `srun` propagates your current environment to the compute node, so the module needs to already be loaded before you call `srun`, not after:

```bash id="v3k8lp"
```bash
module load matlab
```

```bash id="v3k9lm"
```bash
srun --partition general matlab -batch "my_program"
```

Expand All @@ -96,7 +96,7 @@ Notes:

Create a submission script named `my_matlab_job.sbatch`.

```bash id="x2n5ad"
```bash
#!/bin/bash

#SBATCH --job-name=my_matlab_job
Expand All @@ -119,7 +119,7 @@ matlab -batch "my_program"

Submit the job from your home directory:

```bash id="c4w8pq"
```bash
sbatch my_matlab_job.sbatch
```

Expand All @@ -138,54 +138,54 @@ sbatch my_matlab_job.sbatch

All output is written to:

```text id="z1r8tt"
```text
slurm-<jobid>.out
```

Monitor output live with:

```bash id="t6v9gh"
```bash
tail -f slurm-<jobid>.out
```

---

## Commands Used (for Debugging)

```bash id="a8m3kf"
```bash
module avail matlab
```

List available MATLAB versions.

```bash id="k2v9sd"
```bash
srun --pty bash
```

Request an interactive compute node session.

```bash id="u7p1wx"
```bash
module load matlab
```

Load MATLAB module.

```bash id="m9c2qa"
```bash
matlab -batch "my_program"
```

Run MATLAB script in batch mode.

```bash id="b5n7ld"
```bash
sbatch my_matlab_job.sbatch
```

Submit job to Slurm.

```bash id="r3q8yt"
```bash
tail -f slurm-<jobid>.out
```

Monitor job output.

*This QuickByte was validated on 6/23/2026*
*This QuickByte was validated on 8/3/2026*