gBAR

Matlablogo.pngMATLAB (matrix laboratory) is a numerical computing environment and fourth-generation programming language. Developed by MathWorks, MATLAB allows matrix manipulations, plotting of functions and data, implementation of algorithms, creation of user interfaces, and interfacing with programs written in other languages, including C, C++, Java, and Fortran.

Although MATLAB is intended primarily for numerical computing, an optional toolbox uses the MuPAD symbolic engine, allowing access to symbolic computing capabilities. An additional package, Simulink, adds graphical multi-domain simulation and Model-Based Design for dynamic and embedded systems.

In 2004, MATLAB had around one million users across industry and academia. MATLAB users come from various backgrounds of engineering, science, and economics. MATLAB is widely used in academic and research institutions as well as industrial enterprises.

- Taken from Wikipedia.


Starting Matlab from the G-bar

  • Logging into the G-bar via ThinLinc.
  • Choose the menu item "Matlab" under "DTU" -> "Mathematics"

matlab_via_menu.png

 or directly in a terminal by typing:

$ matlab &

The & lets you continue using the terminal, although you have just started a program.

To run different versions:

Applications Menu -> DTU -> xterm (application node)

Then for version 2017a

matlab920

(type matlab then tab tab to see the other versions)


How to get Matlab for your own computer

The G-bar also provides Matlab as a download for students and employees. Different versions can be downloaded from the downloads page downloads.cc.dtu.dk in .iso format (The linux version will only run on a 64Bit OS). The native installer from Mathworks own homepage can also be used. Different toolboxes can be chosen for download as well.

In the "Matlab"->"Student" directory, a complete guide on how to install Matlab is also provided.

matlab_download.png

The guide is found as a .pdf file with the name Guide_for_End-Users_of_TAH_Student_License.pdfIt is essential that all the steps are followed correctly or it will not work. 

It is a requirement to create an account at Mathworks in order to obtain a license. When this account is created it is very important that the email which is associated with the account, is a student email from DTU or the license will not work.

If you are a DTU employee or Phd, you must use the staff license, not the student license.


How to use Matlab

When opening Matlab you will see a bunch of windows as following:

  • Command Window
  • Editor
  • Workspace
  • Current Directory
  • Command History

Command

The Command window is where you can write commands to Matlab. E.g. asking Matlab to open files, do simple calculations etc.

Command Window

This window is not for large simulations since the commands cannot be stored and retrieved later. For this you want the Editor window.

Editor window

The Editor window isn't visible at first, you have to open or create a script - a M-file - before it'll appear. It is used to modify these M-files.

Editor Window

In M-files you can create scripts to do different types of simulations with iterations and so on.

Workspace window

In the Workspace window you can see a complete list of all your currently active variables.

Workspace Window

It is possible to save the current workspace state and load it later if needed.

Current Directory window

In the Current Directory window you can see the directory structure for your currently selected directory.

Current Folder Window

Your script, M-file, has to refer to paths starting from the current selected folder.

Command History

In the Command History window you can see a full list of commands you have executed as to backtrack your steps.

Command History Window

Troubleshooting Matlab

Matlab will not start, error message: unable to initialize com.mathworks.mwswing.MJStartup

Remove the file classpath.txt in your home directory, and start Matlab again.

Matlab will not start, only the splash screen shows, and then nothing

Remove the file classpath.txt in your home directory, and start Matlab again.

I get a screen full of (Java) error messages when trying to open Matlab or the Matlab editor.

Check if you have a file called classpath.txt in your home directory, and remove this file before you start Matlab.

I use surf to plot a 3d surface, but the plot is empty

This is a bug in Matlab, and appears only if you use the new version for the first time, and still have the information bar ("Note new toolbar buttons ...") active. Close this bar by clicking on the 'x' to the right, and the figure should appear.

I can not get the | (pipe) character.

Due to an error in programs with a Java GUI (like Matlab) it is difficult to make a | (pipe). You can get a | by pressing Shift, Alt Graph and the button with <, > and \.

I would like to save the Matlab search path, but Matlab can not save the path

You should make a folder called matlab in your home directory - it is important that the folder is named matlab in lower-case letters. If you save the search path to this folder Matlab will use this search path in all further Matlab sessions.


Which toolboxes are available?

You can see the list of available toolboxes (and versions) by running

ver

in a Matlab session. Please note that DTU does not have an unlimited amount of licenses for all toolboxes, and some toolboxes may thus be unavailable at certain times.

 


The license is about to expire - what to do?

If you see this message on a computer with a network license, e.g. in the databars, don't worry!  We will make sure that the new license is in place before the expiration date.

If you see this message on your own computer with a stand-alone license, do the following:  In the Matlab GUI, go to 'Help' -> 'Licensing' -> 'Update license ...'.  This should solve the problem.

 

If you still get an error message after updating the license, you might have to activate Matlab again.  Start the program 'activate_matlab' (it is installed in the Matlab directory), and activate Matlab again.  The activation key can be found on the software download server downloads.cc.dtu.dk

NOTICE

24
01 2017
Please note that the IT support office has been moved to the DTU library. Latex support remains in 308.
02
12 2015
Want to take advantage of the new GitLab service, or perhaps move your existing repos project over? Check out http://www.gbar.dtu.dk/faq/94-gitlab
07
04 2015
ShareLaTex We now offer ShareLatex, an online mulituser system for making LaTex documents. Check out http://gbar.dtu.dk/faq/91-sharelatex and https://www.sharelatex.com/