Matlab /
RemoteUseDetermine if Matlab is being used remotelyIt can be convenient to have scripts which behave differently if ran locally or remotely. The most common reason would be not having a display when running remotely, which means not being able to display figures (see below for things to fix if that is the case). In order to tell if there is a matlab GUI, the best way is to check with:
which will return 1 if a desktop is running and 0 otherwise. Things to change in Matlab:
Handy OS changesIf you expect to work both locally and remotely on a given computer, it can be handy to have a matlab launcher, which launches matlab differently depending on the situation. A simple example with Bash to launch without graphics when logging in remotely: #!/bin/bash if [ "$SSH_CONNECTION" ]; then echo "Connected remotely, starting Matlab in terminal" /opt/matlabR2015a/bin/matlab -nodisplay -nosplash else echo "Local use, starting Matlab Desktop" /opt/matlabR2015a/bin/matlab fi |