Matlab
Tutorials
- Matlab Tutorial Center: videos and interactive tutorials from Mathworks
- Introduction to Matlab by Gretchen. Note that netCDF toolbox referenced in Introduction is outdated as of Matlab R2008b. netCDF toolbox now embedded and follows C Library toolbox.
Notes on new netCDF toolbox
- If ncdump gives dimensions of (time,yc,xc), netcdf.getVar wants the variables accessed in flipped order. For example:
netcdf.getVar(file_id,var_id,[xc_start yc_start time_start],[xc_count yc_count time_count]);
- The toolbox uses indices that start count at zero! So, if using start array for netcdf.getVar call, be cautious. Once matrix loaded, go back to normal Matlab indexing, which starts at one.
Notes on Plotting Dimensions
For two-dimensional plots (e.g. contour), Matlab wants the “size” of the matrix to be NxM, not MxN. For example, say I have a matrix “test”.
size(test)
ans = 97 80
If I execute the plot command,
contour(x(1:97),y(1:80),test);
Matlab will give me an error about the size of my dimensions being mismatched.
Instead, you have to transpose the matrix for the plot to look as expected. Notice the single quote after the matrix name below.
contour(x(1:97),y(1:80),test');
Be careful of all two-dimensional functions in Matlab, as I often find that NxM is expected! If in doubt, make your dimensions different sizes for tests, then you won't mistakenly be accessing the x-dimension when you mean the y-dimension (or vice-versa).
Matlab comment wrapping
Ever write comments so long that they wrap around to another line, but you have plenty of screen left and want to keep them all on the same line? Here is how to turn comment wrapping off:
- File → Preferences → Editor/Debugger → Language
- Uncheck the 'Autowrap comments' box
(Dan Ariaansen via http://www.mathworks.com/matlabcentral/newsreader/view_thread/236138, 06-09-09)
Google Earth Toolbox
Google Earth Toolbox (I haven't tried this yet, but looks promising- Gretchen)