(4 intermediate revisions by the same user not shown) | |||
Line 10: | Line 10: | ||
== Teaching == | == Teaching == | ||
* Creating synthetic sound signals in Matlab | * Creating synthetic sound signals in Matlab | ||
− | ** [ | + | ** [[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 | ||
− | ** [ | + | ** [[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 | ||
− | ** [ | + | ** [[Fourier_Properties | ECE 301 exercise]] |
− | + | ** [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 | ||
− | ** [ | + | ** [http://web.ics.purdue.edu/~huffmalm/MarioAlias.m Mario Bros Tune with variable sampling] |
− | + | ||
== Research == | == Research == | ||
Line 30: | Line 29: | ||
* Mathworks' '''online community.''' I have borrowed bits of code written by other Matlab users who post on Mathworks' message boards. | * Mathworks' '''online community.''' I have borrowed bits of code written by other Matlab users who post on Mathworks' message boards. | ||
− | I also | + | == 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<source lang="matlab">help function_name | ||
+ | </source> 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: | ||
+ | |||
+ | <source lang="matlab"> | ||
+ | xmag = 0; | ||
+ | for i = 1:length(x) | ||
+ | xmag = xmag + x(i)^2; | ||
+ | end | ||
+ | </source> | ||
+ | exexcutes the same as | ||
+ | <source lang="matlab"> | ||
+ | xmag = x'*x; | ||
+ | </source> | ||
+ | |||
+ | 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 | ||
+ | <source lang="matlab"> | ||
+ | plus2 = @(x) x + 2; | ||
+ | plus2(2) | ||
+ | </source> |
Latest revision as of 08:32, 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
- 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)