Notes from Matlab “World Tour” Seminar 2007
Matlab September 28th. 2007, 1:05pmI attended this seminar in Oxford in May 2007; the notes relate to Matlab 7.1 which was current at that point.
Did you know…?
- You can automatically generate reports from matlab, containing code, figures etc, in HTML, Word,
- PowerPoint or XML form. They are formatted using cell mode; see “Publishing Results” under “Desktop Tools and Development Environment” in Matlab Help.
- There are compiler tools to generate Excel plugins as well as .dlls or .exes
- There is a Distributed Computing Toolbox which provides support for distributing processing across clusters of PCs (allows larger, distributed data arrays, as well as parallel processing)
- Matlab should be able to make use of multi-core processors on a single machine, to support parallel operations
- The Matlab import wizard can import from a range of file formats e.g. Excel, jpeg etc. There is a tick-box to create an m-file which can be used to automate the import process.
- There are in-built functions to support reading of XML files, e.g. xmlread, xmlwrite
- You can do things to data by right-clicking on it in the data window
- When plotting, you don’t need to remember all the commands to pretty-up the result. Just click the “show plot tools” icon on the figure and make the changes you want graphically. Then you can save the commands which have the same effect, using “File -> Generate M-File”. You can also do more sophisticated things like this such as adding more data to your plot, or creating sub-plots.
- Cell mode allows you to divide up files into sections which may be independently tested; also used for publishing (can apply formatting to comments in cells)
- You can add your favourite functions to the GUI shortcut bar
- 3D plots can be rotated around for viewing at different angles
- The statistics toolbox has functions for viewing and manipulating multi-dimensional data, including an optimisation tool to iterate to find an optimal output given multiple input variables
- There is a try - catch statement sequence that can be used to trap errors
- You can call functions in C .dlls, using functions such as calllib, loadlibrary, libfunctions etc. Note the use of functions such as libpointer and libstruct, to create C-style pointers and structures. Can use this to avoid the pain of mex wrapping? See “Matlab Interface to Generic DLLs” under “External Interfaces” in the help.
- If you right-click on a breakpoint, you can set up conditions for breaking, which can include any valid matlab code; e.g. you can run a whole function to evaluate whether or not to break…
- There is an m-lint tool which analyses your code for problems in a similar way to lint in C. Run it on all files in a directory, from the drop-down box in the directory window.
- Running your code from the Profiler tool gives you all kinds of profile info including code coverage, “m-lint” warnings, time spent in each function etc.
- The depfun function will report all the dependencies of a .m file (the Profiler can also be used for this purpose). The Dependency Report tool (run from the drop-down box in the directory window) can do this for all files in a directory
- If you put TODO, FIXME or NOTE in comments, then these can be picked up and listed for all files in a directory, using the TODO/FIXME report tool, run from the drop-down box in the directory window.
- Using the Contents Report tool, you can automatically create a Contents.m file for a directory, listing descriptions for each file in the directory. The contents can then be viewed using help <dirname>
- The Help Report tool will display any help that you have written for all files in a directory. Note that if you use the strings Example, See also, or Copyright, these are picked out separately by the Help Report tool.
- If you need to create a large array and have a problem with available memory, try the undocumented command system_dependent memstats. This shows the available blocks of contiguous memory. Arrays must be held in contiguous memory, so you may need to re-root to get the area you need.
- You can set up a timer which “wakes up” and runs a function every so often. This can allow you to implement a simple form of multi-tasking between different matlab functions, by scheduling functions to run from the timer (see notes on function handles, below)
