Search Contact information
University of Cambridge Home Department of Engineering
University of Cambridge >  Engineering Department >  computing help >  programs

Matlab

Contents

MATLAB is a high performance interactive software package for scientific and engineering computation. MATLAB integrates numerical analysis, matrix computation, signal processing and graphics in an easy-to-use environment where problems and solutions are expressed just as they are written mathematically. To start MATLAB on our system just type matlab in a terminal window or find the Matlab icon in the applications panel (use the greenarrow button).

Introductions

We have various handouts online. Mathworks' own Getting Started with MATLAB is useful. Alternatives are CUED's Getting Started with Matlab (PDF version) and Matlab by Example. The Matlab Primer gives an out of date description of facilities. Using Matlab at CUED (PDF version) lists the added local features, and gives answers to many questions commonly asked at CUED. Mathworks' Using MATLAB gives more details on maths, graphics, object-oriented programming etc.

A Matlab databook (PDF version) is in preparation, aimed at 3rd and 4th years.

See also

  • Introduction to Matlab (MIT OpenCourseWare), especially the Assignments
  • Toolboxes

    Toolboxes are libraries of extra routines. Typing ver inside Matlab lists the other toolboxes that we're licensed to use. If we don't have something you want, try

    Getting help

    Matlab has its own text-only help system (type help from the matlab prompt) and WWW-based documentation (see the Help Desk or type doc). There are some video tutorials you can play (see the Demos sections, especially "Desktop Tools and Development Environment"). Use matlabdoc -a to list documentation files available in the alternative (PDF) format. "matlabdoc -a newfeat", for example, will display the 'New Features' document.

    More answers can be obtained from the Mathworks' search facility including Mathworks (their european mirror site may be faster) also maintains a Support and Customer Service page which includes a facility that lets you search for answers by typing in a keyword, and a MATLAB In Education page that leads to various examples and courses. Some short local articles are now online Articles elsewhere include

    Numerical Computing with MATLAB and Experiments with MATLAB by Cleve Moler are online textbooks.

    If you have problems, you can try using matlab's debug facility (begin with dbstop). Alternatively, local users can look at CUED's Matlab FAQ, mail Tim Love, look at the global newsgroup comp.soft-sys.matlab (a WWW interface is at newsreader.mathworks.com). A list of the newsgroup's Frequently Asked Questions (FAQ) is online.

    Some ancient manuals can be borrowed from the operators in the Engineering dept's DPO. Documentation from other universities is available too.

    Simulink

    SIMULINK is an extension of MATLAB that lets you model a system graphically. It adds to Matlab many features specific to dynamic systems while retaining all of MATLAB's general purpose functionality. See Simulink's user guide for details.

    In January 2007 Mathworks identified bugs in R14SP3 Simulink(R) code generation products, which in rare instances generate incorrect code that is not easily detected. These bugs have been fixed in subsequent releases: R2006a, R2006b, or the upcoming R2007a release, so if you used R14SP3 to generate code, upgrade and regenerate.

    COMSOL

    COMSOL is a FE package. Type "comsol" to run it, or click on its icon. See our COMSOL page for further information. email amb2 with any questions.

    Using Matlab with Fortran and C++

    Matlab can also be used from C++ and fortran as a library of maths and graphics routines. Also C++ and fortran code can be called from within matlab. An Interface Guide is online. Current examples are in /usr/local/apps/matlab/matlabR2007a/extern/examples/ on our Linux servers. Local users using these files on the linux servers should note that some local configuring may be required - see Matlab: configuring mex page.

    We have 1 license centrally maintained for Mathworks' compiler that converts MATLAB programs into stand-alone applications (though the royalty-free MATLAB Compiler Runtime (MCR) needs to be installed for the "stand-alone application" to work). Note that MATLAB's matrix-oriented operations are already highly optimized. As a result, the MATLAB Compiler is unlikely to significantly speed up functions that spend most of their time in MATLAB's built-in indexing, math, or graphics functions, or that are heavily vectorized.

    Optimisation and long jobs

    See the GridEngine documentation before running long jobs. Matlab scripts can often be speeded up considerably with little work - see the Faster Scripts document. The first 2 methods mentioned below have speeded up some CUED programs by a factor of 10 or so.

    Parallelisation

    The Matlab and parallel computing page has information. Newer versions of matlab exploit multi-processors internally. If you run MATLAB R2007a or newer on a multiple-CPU system (multiprocessor or multicore), you can enable "multithreaded computation". It's not set by default but you can set it in Preferences
    multithread
    On our linux servers (which have 4 CPUs, so the 'Automatic' option sets the number of threads to 4) the following graph shows the speed-up factors for a range of tasks
    multithread
    Note that some operations aren't speeded up, whereas others are over 3 times faster (the y axis running from 0 to 3.5). To exploit multi-processors more fully (or to use several machines in parallel) you need extra software. Here are some of the alternatives, not all of which are free.

    See Mathworks' Enhancing Multicore System Performance Using Parallel Computing with MATLAB article.

    New Facilities

    Added facilities include

    Installing Matlab

    Our site-license covers covers the following types of machine within the department - HP, Apple OSX, Compaq (DEC), SUN, Linux RedHat and machines running 32-bit/64-bit versions of Microsoft Windows which are connected to the department's network.

    See the On-line Installation of Windows version of MATLAB page for Windows machines.

    Mail other installation requests to pc-support or research-support. Staff who need stand-alone versions of MATLAB should contact The Mathworks direct.

    It's possible to have CUED's Matlab installed on your own machine as long as the machine is connected to the internet when matlab is used. See

    See our MATLAB Licensing Information and MATLAB - Frequently Asked Questions on Licensing at CUED for licensing details.

    Old versions of Matlab are installed on CUED's central system under /usr/local/apps/matlab/

    Purchasing Additional Licences for ToolBoxes

    Mail amb2 for license details.

    Price List for Matlab

    MATLAB Academic Price List.

    Student Version (Buy Your Own Copy)

    Students who need MATLAB on desktops/laptops (non-networked) can order it from Bookshops (this includes a book, Simulink and some Symbolic Toolbox functions). See Mathworks' Student Version page for details.

    Any additional toolboxes (priced at US$59) can be purchased directly from the American web site using a credit card. These are only for bona fide students.

    octave is free and may be useful to you. It's used in CUED undergraduate courses and is on the MDP Resource disc.

    © Cambridge University Engineering Dept
    Information provided by Tim Love (tpl)
    Last updated: December 2009
    Valid XHTML 1.0 Transitional