Here's a very quick intro to some of the basic concepts and syntax of Matlab. The hope is that after covering some of these basics, and those described in the other Matlab docs pages above, you'll be able to troubleshoot SPM and Matlab errors to some degree. Experienced Matlab programmers may find most of this redundant, but there's always more you can pick up in Matlab, so please, if you experience folk've got tips and tricks to suggest, add them onto these pages!
This page looks specifically at the most basic of basics. For info on how to read m-files and m-file programming concepts, check out MatlabProgramming. As well, MatlabPaths answers questions about modifying your search paths, and MatlabDebugging touches specifically on strategies for troubleshooting - how to get more information, what parts of error messages to look for, and how you can dig through a script to find what's gone wrong.
If you take nothing else away from this page, take this: The Matlab tutorial, contained within the program's help section, is terrific. It'll teach you a lot of the basics of Matlab and a lot of things you wouldn't think to learn. The progam help is always a great place to go for more info or to learn something new. Nothing will help your troubleshooting and programming skills like curiousity - when you hit something you don't know or recognize, spend a couple minutes trying to figure out what it is, with the Matlab and SPM help. If your help within the program isn't working, it's all online at the Mathworks website, here: http://www.mathworks.com/access/helpdesk/help/techdoc/matlab.shtml.
As well, if you type help command into Matlab, where command is some Matlab function name, you'll almost always get a quick blurb telling you something about the function and how it's supposed to operate. It's invaluable for reference or learning on the fly.
In the following, text in fixed-width font are commands that you can type directly into Matlab.
Here are some quick basics on Matlab code and what it all means. You don't need to be expert on all of this, but it may help you understand what an error message or piece of script means - a sort of Rosetta stone, if you will.
Sets of numbers (or characters, or other things) in Matlab are arranged in arrays - basically rectangles of rows and columns of numbers. Arrays can be only a single number - those are called scalars. They can also be single rows or columns - those are called vectors. Two-dimensional arrays (with multiple rows and columns) are pretty common, but arrays can also be three-dimensional, or even four- or more-dimensional. If you want to access a single element of the array, you use array notation, which puts parentheses after the variable name to specify which element. So if I have a 4-by-4 array called a, a(3,2) refers to the element in the third row, second column. Array notation always refers to row first, column second, other dimensions afterwards in order. You can type a(3,2) by itself in Matlab and it'll tell you what's in that spot, or you can use = to reassign that number, with a command like a(3,2) = 16. If you have a vector, you can use only one number in the parentheses - something like a(4) = 56.