MatLab-Teaching

From Research Computing Center Wiki
Revision as of 17:09, 17 January 2019 by Shtsai (talk | contribs) (Created page with "Category:TeachingCategory:SoftwareCategory:OtherCategory:ProgrammingCategory:Graphics === Category === Other, Programming, Graphics === Program On ===...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Category

Other, Programming, Graphics

Program On

Teaching

Version

R2018b (9.5.0.944444)

Author / Distributor

The MathWorks (see http://www.mathworks.com)

Description

Matlab is a high-level technical computing language and interactive environment for algorithm development, data visualization, data analysis, and numeric computation.

Running Program

Also refer to Running Jobs on the teaching cluster


  • Version R2018b is installed in /usr/local/apps/MATLAB/R2018b/bin. In order to use this version of Matlab, please first load the matlab/R2018b module with
module load matlab/R2018b


Running Matlab interactively

The compute nodes, including the interactive nodes, cannot forward X11 applications to the user's local machine. We recommend using Matlab in command-line mode (without the GUI) on the teaching cluster. If you need to use the GUI, you can run it on the login node of the teaching cluster. Please note that the application will be very slow when run with a GUI. If you want use the GUI, please note that you will need an X client on your local machine and configure ssh to tunnel X11 (please see the [Frequently Asked Questions] page).


1. To run with the graphical front-end on the login node:

module load matlab/R2018b

matlab &

2. To run without the graphical front-end on a regular node:

qlogin

module load matlab/R2018b

matlab -nodisplay


Running Matlab in the batch queue

Matlab can also be run on the batch queue. To do this, first create a MatLab M-file with the MatLab commands. Then use a job submission file to submit this job to the batch queue.

Sample MatLab M-file (matrixinv.m):

n = 500; 
Q = orth(randn(n,n));
d = logspace(0,-10,n);
A = Q*diag(d)*Q';
x = randn(n,1);
b = A*x;
tic, z = A\b, toc
err = norm(z-x)
res = norm(A*z-b)

import java.lang.System
java.lang.System.exit(0)

Sample job submission script file (sub.sh):

#!/bin/bash
#SBATCH --job-name=matlabjob
#SBATCH --partition=batch
#SBATCH --mail-type=ALL
#SBATCH --mail-user=username@uga.edu
#SBATCH --ntasks=1
#SBATCH --mem=2gb
#SBATCH --time=08:00:00
#SBATCH --output=matlab.%j.out
#SBATCH --error=matlab.%j.err

cd $SLURM_SUBMIT_DIR
ml matlab/R2018b
matlab -nodisplay < matrixinv.m

In the real submission script, at least all the above underlined values need to be reviewed or to be replaced by the proper values.


To submit either of the two sample files sub.sh to the queue:

sbatch sub.sh


NOTE

At job exit time, you might get a Java error of the form

com.mathworks.util.ShutdownRuntimeException: Java is shutting down
  ...

Although this error is harmless (it occurs after the MatLab program finishes), you can avoid it by adding the following two lines of code to your MatLab program (M-file):

import java.lang.System
java.lang.System.exit(0)


Documentation

Some documentation and sample files are available in /usr/local/apps/MATLAB/R2018b/help

Installation

Version 2018b

Installed in /usr/local/apps/MATLAB/R2018b.

Available toolboxes: Almost all toolboxes for which UGA has a license. For details, see the directories in /usr/local/apps/MATLAB/R2018b/toolbox

System

64-bit Linux