Introduction Q1.1 What is MATLAB?
MATLAB is a commercial software package written by The Mathworks (http://www.mathworks.com). Quoting from their web page:
Numeric computation, technical graphics and visualization, and an intuitive programming language for applications in engineering and science
MATLAB is a complete environment for high-level programming, as well as interactive data analysis. MATLAB excels at numerical computations, especially when dealing with vectors or matrices of data. Symbolic math is available through an add-on toolbox that uses a Maple kernel.
There are too many toolbox add-ons to describe here. Poke around the web site if you have some interest.
Questions about the name "MATLAB" often arise. MATLAB stands for "MATrix LABoratory". See <http://www.mathworks.com/access/ helpdesk/help/techdoc/learn_matlab/ch1intro.shtml> for an overview of MATLAB. 
Basic Q2.1 Why does MATLAB only calculate to 4 significant digits?
It doesn't. It uses full double-precision floating point numbers to calculate everything. By default it only prints a few decimal places to the screen. You can change this using the command `format long'. Type `help format' for more information. 
Q2.2 How can I find local maxima in a vector array?
You can use the following one-line function to determine the indices of the local maxima.
function index = localmax(x) index = find( diff( sign( diff([0; x(:); 0]) ) ) < 0 ); 
Programming Q3.1 Can I read a text file with a certain format?
Yes. If the file has nothing but numbers separated by whitespace, and has a constant number of columns through the entire file, you can just type `load myfile.txt'.
The function `DLMREAD' is more flexible and allows you to read files with fields delimited by any character.
The function `TEXTREAD' is more flexible still and allows you to skip lines at the beginning, ignore certain comment lines, read text as well as numbers, and more. Type `help textread' for more info.
If none of these suit your needs, you can always use the low-level file I/O functions `FOPEN', `FREAD', `FSCANF', `FGETL', `FSEEK' and `FCLOSE' to read the data however you would like. 
Q3.2 How do I fix "Out of Memory" problems?
A frequent variant of this question is: "I have 512M of RAM, and 2G of swap space. Why can't I create this 200M matrix?"
Simple answers first: Remember that double precision floats take up 8 bytes. So a million element vector takes up 8Mbytes. Be sure you're estimating properly.
Many operations need to create duplicate matrices. For example, B=inv(A.') must create a temporary variable the same size as A to hold the transpose, and B is again, the same size as A.
If you're sure your matrices are reasonably sized, then read all of TMW Tech Note 1106, a great reference: <http://www.mathworks.com/support/tech-notes/1100/1106.shtml> 
Graphics Q4.1 Can I create a pi/sigma/superscript in my ticklabels?
Not directly... MATLAB does not interpret TeX strings in ticklabels. You can play games with placing text by hand. The following MathWorks solutions may give you some guidance:
<http://www.mathworks.com/support/solutions/data/27450.shtml>
and
<http://www.mathworks.com/support/solutions/data/5375.shtml>
There are also some free third-party software packages you can use to accomplish this.
Doug Schwarz has written a Styled Text Toolbox that does this. It is freely available at:
<http://www.servtech.com/~schwarz/stextfun/index.html> 
Q4.2 How can I set default handle graphics properties?
There are probably several hundred of these default handle graphics options. Rather than trying to remember any particular one, the best thing is to learn the general principle behind all of these default handle graphics properties. The basic call to insert into your startup.m file is :
set(0,'DefaultObjectnamePropertyName',Value)
For line objects, here are a few examples:
set(0,'DefaultLineMarkerSize',12); set(0,'DefaultLineMarker','d'); set(0,'DefaultLineLineWidth', 2);
Similarly, you can use these statements for axes objects:
set(0,'DefaultAxesLineWidth', 2); set(0,'DefaultAxesXGrid','on'); set(0,'DefaultAxesTickDir','out'); set(0,'DefaultAxesTickLength',[0.015 0.015]); set(0,'DefaultAxesFontName','Arial')
For more details, do a full text search for 'Defining Default Values' in the R12 online help, and click on the very first hit. Also see the following entries in the R12 online help:
* Graphics Object Hierarchy * Types of Graphics Objects 
Q4.3 How can I set the focus in my GUI?
You can't. One hopes that The MathWorks will include this often-requested feature in a future, but there is no guarantee.
Related to this, changing the stacking order of your GUI elements _might_ allow you to set the tab order, but this seems to not always work. 
Math/Algorithms Q5.1 How does the backslash operator work? What does it do?
For full matrices, pseudocode describing the algorithm can be found here:
<http://www.mathworks.com/support/solutions/data/22317.shtml>
For sparse matrices, the URL is:
<http://www.mathworks.com/support/solutions/data/21798.shtml>
Also for sparse matrices, you can turn on monitoring routines that show you some of the steps. Use `spparms('spumoni', 1)', or `spparms('spumoni', 2)' 
Q5.2 Why does MATLAB return an complex number for (-8)^(1/3)
In the same way there are two solutions (plus and minus) for the square root of a positive number, there are multiple solutions for roots of negative (and complex) numbers. If you express the number in magnitude*exp(i*theta) form, the cube root (for instance) takes the form (magnitude^(1/3))*exp(i*theta/3*k), for k=1:3.
-8 is 8*exp(i*pi), so the cube roots are 2*exp(i*pi/3), 2*exp(2*i*pi/3), and 2*exp(3*i*pi/3). The last one simplifies to -2.
MATLAB always returns the _first_ solution counter-clockwise from the positive real axis. Armed with this knowledge, you can compute all or some particular root. For instance, if you want the negative real cube root, simply take the cube root of the absolute value of the number, and negate it.
For a different wording and more information, see <http://www.mathworks.com/support/solutions/data/2998.shtml>.
Finally, Joe Sababa <joesababa@yahoo.com> suggests in <http://groups.google.com/groups?selm=eeada27.1@WebX.raydaftYaTP> a method to find all the roots at once:
Find the roots of a polynomial: P=[1 0 0 27]; roots(P) 
|