I'm getting some new students soon, who will be writing MATLAB code. They're new to MATLAB, but they have experience coding in Java and C++.
I'm going to have them go through the Getting Started section of the MATLAB help. In addition, I want to give a small tutorial with the goal to prevent them from making some of the most common mistakes people make when switching to MATLAB (e.g. "MATLAB starts counting at 1"), and show them some features that they may not be aware of when coming from other languages (e.g. "you can subtract a scalar directly from an array, and for vectors, there's bsxfun").
What are the most important things I should tell them?
For those coming from C-family languages, the element-wise operators are new. It took me a couple of months to discover the
./
and.*
operators. Before that, I used to write for loops for element-wise operations. So perhaps that's something that should be pointed out.With respect to unexpected or non-intuitive MATLAB features that may cause them confusion, there are some good pointers in this question:
With respect to cool time-saving/efficiency tricks, this other question has some nice examples:
And for a few potentially more advanced topics, you can refer to the answers to this question:
Now for my $0.02. Based on the sorts of questions I've seen asked most frequently on SO, I'd say you will want to make sure they have a good understanding of the following concepts:
And here are some neat features that are already implemented in MATLAB that may save them some time and effort:
Enough snippy comments, here's something of an answer too:
That should be enough to keep them busy for an hour or so.
To clarify, I propose these topics to help you teach your students to avoid common Matlab errors including;
I agree with previous answers, but I'd say indexing is the first and the most important and complex concept in studying MATLAB. I saw many C programmers starting with MATLAB just write loops, a lot of loops, something ridiculous like
instead of simple
a=1:10;
.So I'd suggest them to read about matrix programming concepts:
As for productivity, I would add that knowing how to use editor's cell mode is very useful.
MATLAB is conceptually in some ways very different from other languages you mentioned:
global
andpersistent
variables arestatic
in Javadouble
private
and @TYPE folders for visibility scopingvarargin
/varargout