# Oscar: MATLAB

## Loading and Launching MATLAB

1\. Open the Terminal and use the following commands at the command line.

2\. `module avail matlab` to list all the available matlab versions (if running Oscar in PuTTY, pasting text is done by right-clicking).

3\. `module load matlab` to load the latest version of matlab (R2023a). Other versions can be specified with the command `module load matlab/R2019a`.

4\. `matlab` to launch the MATLAB app.

## Installing MATLAB Packages such as YALMIP

MATLAB script packages, such as [YALMIP](https://yalmip.github.io/ "https://yalmip.github.io/"), can be installed directly by the user on their Oscar account.

1\. Open the Terminal and connect to Oscar.

2\. Navigate to your home folder by typing `cd ~`

3\. `mkdir -p MATLAB`

4\. `wget -O yalmip.zip <a class="urlextern" href="https://github.com/yalmip/yalmip/archive/master.zip" rel="ugc nofollow noopener" target="_blank" title="https://github.com/yalmip/yalmip/archive/master.zip">https://github.com/yalmip/yalmip/archive/master.zip</a>`

5\. `unzip yalmip.zip`

6\. In MATLAB, add the YALMIP-master directory to your path.

<div id="bkmrk-in-the-matlab-file-b"><div>1. <div>In the MATLAB file browser, navigate to the MATLAB folder you created in your home folder. `cd ~/MATLAB`</div>
2. <div>Right click on the YALMIP-master folder.</div>
3. <div>Select Add to Path &gt; Selected Folders and Subfolders. This adds the YALMIP folders to your path.</div>

</div></div>7\. To save your MATLAB path, use the savepath command in the MATLAB command prompt. `savepath ~/MATLAB/pathdef.m`

YALMIP also requires a solver like [SDPT3](https://github.com/SQLP/SDPT3 "https://github.com/SQLP/SDPT3"). The steps below add SDPT3 to MATLAB.

1\. Open the Terminal.

2\. `cd ~/MATLAB`

3\. `wget -O sdpt3.zip <a class="urlextern" href="https://github.com/sqlp/sdpt3/archive/master.zip" rel="ugc nofollow noopener" target="_blank" title="https://github.com/sqlp/sdpt3/archive/master.zip">https://github.com/sqlp/sdpt3/archive/master.zip</a>`

4\. `unzip sdpt3.zip`

5\. In MATLAB, add the sdpt3 directory to your path.

<div id="bkmrk-in-the-matlab-file-b-0"><div>1. <div>In the MATLAB file browser, navigate to the MATLAB folder you created in your home folder. `cd ~/MATLAB`</div>
2. <div>Right click on the sdpt3-master folder.</div>
3. <div>Select Add to Path &gt; Selected Folders and Subfolders. This adds the SDPT3 folders to your path.</div>

</div></div>6\. To update/save your MATLAB path, use the savepath command in the MATLAB command prompt. `savepath ~/MATLAB/pathdef.m`