Line 10: Line 10:
 
== Teaching ==
 
== Teaching ==
 
* Creating synthetic sound signals in Matlab
 
* Creating synthetic sound signals in Matlab
** [https://kiwi.ecn.purdue.edu/rhea/index.php/Homework_1 ECE 301 exercise]
+
** [[Homework_1 | ECE 301 exercise]]
 
** [http://web.ics.purdue.edu/~huffmalm/301SU09/Mario.m Mario Bros Theme Tune]
 
** [http://web.ics.purdue.edu/~huffmalm/301SU09/Mario.m Mario Bros Theme Tune]
 
* Understanding convolution using Matlab
 
* Understanding convolution using Matlab
** [https://kiwi.ecn.purdue.edu/rhea/index.php/Homework_2 ECE 301 exercise]
+
** [[Homework_2 ECE 301 exercise]]
 
** [http://web.ics.purdue.edu/~huffmalm/myconv.m Custom, illustrative convolution function]
 
** [http://web.ics.purdue.edu/~huffmalm/myconv.m Custom, illustrative convolution function]
 
* Understanding Fourier expansions of periodic signals
 
* Understanding Fourier expansions of periodic signals
** [https://kiwi.ecn.purdue.edu/rhea/index.php/Fourier_Properties ECE 301 exercise]
+
** [[Fourier_Properties | ECE 301 exercise]]
 
** [http://web.ics.purdue.edu/~huffmalm/FourierApprox.m Approximation of square wave with finite number of Fourier terms]
 
** [http://web.ics.purdue.edu/~huffmalm/FourierApprox.m Approximation of square wave with finite number of Fourier terms]
 
* Understanding sampling and aliasing
 
* Understanding sampling and aliasing
** [https://kiwi.ecn.purdue.edu/rhea/index.php/Fourier_Properties ECE 301 exercise]
+
** [[Fourier_Properties ECE 301 exercise]]
 
** [http://web.ics.purdue.edu/~huffmalm/MarioAlias.m Mario Bros Tune with variable sampling]
 
** [http://web.ics.purdue.edu/~huffmalm/MarioAlias.m Mario Bros Tune with variable sampling]
  

Revision as of 08:28, 6 October 2010

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

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 type
help function_name
to (re)learn how to use it. There is more extensive documentation in the Help dropdown menu. If you're still looking for more answers, try the Mathworks site.

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)

Alumni Liaison

Basic linear algebra uncovers and clarifies very important geometry and algebra.

Dr. Paul Garrett