Loren on the Art of MATLAB

April 21st, 2009

Learning MATLAB

Do you learn best by reading, watching, or doing? I do best with a combination of all three for learning technical material.

Contents

First Step - Motivation

For me, the first step in learning is finding out that some feature or technique exists. This often happens in a seminar or a discussion, sometimes by reading a paper. For me it helps if there's motivation to give me some context. And it's especially helpful if there's an example solving a problem similar to one I want to solve!

Second Step - Grab Code and Modify

Having decided it's time to learn about some particular algorithm or some feature, what to do next? For some, the first instinct will likely be to search the web looking for code or references. If I already have the software, I tend to look in the documentation, and, if possible, find example code close enough to what I hope to do. I then make a copy and modify from there. But that's just my learning style.

What's Your MATLAB Learning Style?

I'm guessing since you are reading this blog that reading examples is at least partially help to you. There are some other resources, beyond all the blogs and code on MATLAB Central.

For people new to MATLAB, you can get a great start here.

I've mentioned Cleve's books here. In addition to examples, videos and demos on The MathWorks web site, there is now a MATLAB Channel on YouTube.

How do you learn best? Where do you go for your MATLAB information? Post your thoughts here and please include links to any additional valuable references you use for learning MATLAB.


Get the MATLAB code

Published with MATLAB® 7.8

9 Responses to “Learning MATLAB”

  1. Joao replied on :

    I learned MATLAB, during the first year of my undergraduate studies, by reading through the help files. In fact, I fell in love immediately due to its simplicity. I had gone through the cumbersome process of learning other languages for which no centralized good documentation was available (at least to me), and I remember in the beginning thinking that 80% of the value of MATLAB was in the help docs whereas only 20% was in the actual software.

  2. Daniel replied on :

    I originally learned Matlab at university with the help of a booklet with walk-through examples. Nowadays, most of what I learn is from this blog and the competitions. I would love a structured book, but none of the books I have found really get into the advaced stuff. Where is the book that skips the intro, jumps straight to bsxfun and then takes it from there?

  3. Loren replied on :

    Daniel-

    Any thoughts on what such a book might look like? A collection of nuggets, a narrative with detailed examples,…???

    –Loren

  4. George Kapodistrias replied on :

    I started on MATLAB in 1995 while in Grad School mostly as tool to look at numerical results generated by FORTRAN code (also used Mathematica quite a lot for the same purpose). Back then the Help files were the main source for learning. By 1996 I replaced FORTRAN with MATLAB for all programming. In addition, MATLAB won over Mathematica due to the superior graphic packages and that it is an actual programming language (in a general sense). Since then MATLAB has become a love and I use it most of my work and all of coding entertainment! In my experience I have found that small programming constructs provide the best learning experience for people who have some experience with programming (any language). In general, my belief is that the best way to teach something is to keep the material simple. BTW, I always recommend the NCM book by C. Moler (at least Ch. 1-3) to people that in the first stages of learning MATLAB.

  5. per isakson replied on :

    Now, I have spent too much time trying to learn INPUTPARSER (R2008a). I have made some coding expreriments. Some of these work nicely, some produce “wrong” result and some give runtime errors. I cannot see the reasons to the “wrong” results and errors.

    My goal is to develop a “programming pattern” to use in all my new functions, which are not time critical.

    1. I printed some documentation, e.g “Parsing Inputs with inputParser”. I cannot find a precise description of the input argument lists, which should be possible to handle with inputParser. (There is no m-code to look in.) I have to figure out from the examples (publish_ip).

    2. I did the exercises with publish_ip - no problems so far.

    3. I modified publish_ip and run soon into problems. I searched “Bug reports”, “Technical notes”, the File Exchange and the Newsgroup. I found a bug-report (ID 511503) and a tech-report (Solution ID: 1-97TD7R).

    4. I did a number of fairly systematic experiments. I have problems. Leaving out Optional arguments, which are followed by ParamValue-pairs in the argument list, give unexpected results, e.g. “my versions” of publish_ip(’script’, options ). It has something to do with the validator of the Optional argument; e.g. “@ischar” doesn’t do the job as separator. Have I misinterpreted the documentation (or missed something) or doesn’t inputParser behave as described in the documentation?

    This description is very detailed. However, I would say the situation is fairly typical for me together with Matlab. Part of the problem is that I read the manual and is a bit stubborn.

    My learning curve would benifit from more detailed and precise (/formal) documentation (in addition to current documentation).

    I would love a feature in Matlab that would allow me to make my own notes in the documentation. Close to “See also” there should be an icon, e.g. paper-clip, which opens a little editor for me to document my findings. In addition it must be easy to move this notes to the next release of Matlab.

    / per

    PS Now I will contact tech support.

  6. Anshul Kundaje replied on :

    I think MATLAB probably has the best documentation compared to most other programming languages. So it isn’t hard to pick it up from the docs. However, it is time consuming to wade through it all.

    If you are pretty good at coding in some other language X (say R or python or C++), I think the best way to learn MATLAB is if you can locate code snippets that map all the basic operations you need from language X to MATLAB.

    I have actually been using the reverse strategy to quickly catch up with syntactic details of R and python after being a MATLAB junkie for a while.

  7. Loren replied on :

    Thanks for the complimentary words about MATLAB documentation.

    Anshul- I am curious what is leading you to use R and Python currently.

    –Loren

  8. Anshul Kundaje replied on :

    I needed to run/modify someone else’s code that was written in R and python. I still prefer MATLAB.

  9. Sung Soo replied on :

    I’m with Daniel about the advanced Matlab tip book. It’ll be really helpful if we have a book like “Rails Recipes”. (http://www.pragprog.com/titles/fr_rr/rails-recipes) I know that all advanced information is in the help documents but it is difficult to find it.

Leave a Reply

Wrap code fragments inside <pre> tags, like this:

<pre class="code">
a = magic(3);
sum(a)
</pre>

If you have a "<" character in your code, either follow it with a space or replace it with "&lt;" (including the semicolon).


Loren Shure works on design of the MATLAB language at The MathWorks. She writes here about once a week on MATLAB programming and related topics.

  • Loren: Paul- There *are* issues depending on the sizes of ii and jj. And it’s a bit complicated, but really...
  • Loren: Bob- You don’t say what happens when you run your code. Can you please explain more. It looks like you...
  • Loren: Kishore- It is not clear to me what you are trying to actually achieve. If you want to concatenate the 4...
  • Kishore: sorry, in the previous code mat2cell(c,[19 121],[19 134],[19 84],[19 107])
  • Kishore: Hi Loren, Why does the following not work? data_classwise = [19x121 double] [19x134 double] [19x84 double]...
  • Paul Jackson: Loren, Are there any aspects of empty matrices that may be tricky when they are used as indices into...
  • Bob: Hi Lori, Im trying to process Unicode text files from more than one different locales than the standard latin...
  • Loren: Ben- The reference link in my post documents the behavior of sum([]) and prod([]) (although the prod part only...
  • Ben: Loren/Andrey, A further advantage of having sum([])==0 and prod([])==1 is that it’s consistent with array...
  • Loren: OysterEngineer- I will SO take you up on that offer. Can’t wait for a good reason to visit now....

These postings are the author's and don't necessarily represent the opinions of The MathWorks.