Landis Huffman's Matlab Page
Matlab has proved to be an invaluable tool for my work in signal processing engineering. Its extensive library of functions and seamless incorporation of graphical visualizations makes it incredibly useful for building prototypes and debugging at a system or algorithm level. It's ease of use, and freedom from the bothers of monotonous low-level implementation details provide an advantage over C and other lower-level programming languages for research purposes.
Matlab is also incredibly useful in the teaching arena, providing a vessel for hands-on, interactive learning of abstract concepts which are often taught in the stale confines of a chalk board.
Below, I give an overview of my use of Matlab in teaching and research. Enjoy! Huffmalm
Teaching
- Creating synthetic sound signals in Matlab
- Understanding convolution using Matlab
- Understanding Fourier expansions of periodic signals
- Understanding sampling and aliasing
Research
The bulk of my research is implemented in Matlab. My work in video object tracking (see here) has involved the construction a human tracker implemented entirely in Matlab. The code is too extensive to post, but I mention here some key pieces of the software provided by Matlab's built-in capabilities.
- Matlab's Object Oriented framework
- Incorporation of some custom C code through mex
- OpenGL rendering within a Matlab Figure
- Multimedia packages (mmreader, etc)
- Mathworks' online community. I have borrowed bits of code written by other Matlab users who post on Mathworks' message boards.
Matlab Tips
Matlab is a very powerful tool with an extensive number of features. Learning to use all of them to their full potential takes lots of time and practice. Here are a few things I have learned "the old fashioned way" (i.e. on my own):
Use "help"
Matlab has great built-in documentation. When working with a new function (or even one very familiar to me), I will often typehelp function_name
Use vectorization
Matlab computes matrix and vector products very quickly, but as a scripted, noncompiled language, executes loops more slowly. It is often best to use matrix multiplies in place of loops, where possible. For instance:
xmag = 0; for i = 1:length(x) xmag = xmag + x(i)^2; end
exexcutes the same as
xmag = x'*x;
The function reshape and the "concatenators" (e.g. x(:) creates a single column) can help format data for a matrix multiply. The functions repmat and kron are also good for duplicating vectors/matrices for batch matrix operations.
Learn handles
You can execute some slick stuff using handles in Matlab. For starters, Matlab figures and elements within figures all have "graphics handles." The handle is like a "pointer" to the object, and may be used to set graphics properties within a Matlab script. Try get(gco), get(gca) or get(gcf) to see the graphics properties of the current object, axis or figure, and the set command to change them.
Handles are more general than graphics. Even functions have handles. Try
plus2 = @(x) x + 2; plus2(2)