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?
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
for i=1:10
a(i)=i;
end
instead of simple a=1:10;
.
So I'd suggest them to read about matrix programming concepts:
- How to create simple vectors and matrices
- Which variables can be used for indexing
- How to create and apply indexes
- Logical operations and functions, logical and numeric indexes (find function)
- Indexing right and left side of expression
- Difference between indexing numerical matrices and cell arrays
- How to use indexes as output from different functions, like sort, unique, ismember, etc.
- You cannot apply indexes to intermediate results
As for productivity, I would add that knowing how to use editor's cell mode is very useful.
Enough snippy comments, here's something of an answer too:
- The Matlab desktop: what all the windows are for, dragging code from the history back into the command window, the variable inspector, etc.
- Plotting: not just the plot command, but how to use the plot GUI tools, and how to create an M-file from a graphic.
- M-files for scripts and functions, and the key differences between them.
- M-Lint, the profiler.
- Use Matlab as a vehicle for teaching the perils and pitfalls of floating-point arithmetic.
- Getting help: at the command line, on the web, documentation, the file exchange, ...
- Set path and the current working directory.
- Importing data from files, exporting data to files, loading and saving.
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;
- Unproductive use of the tool, retyping commands which can easily be recalled from the history, using C (or Java) style file reading commands instead of uuimport, slowly typing scripts to draw graphics when Matlab can do it for you, wondering what all the little orange lines in the editor right margin mean and the squiggly underlines, trying to figure things out for themselves when the help facilities could tell them, tons of other stuff that many much more experience Matlab users have taken ages to learn.
- Floating point arithmetic is not real.
- and probably a lot of other stuff too.