User Tools

Site Tools


atmos:software:matlab

Matlab

Tutorials

  • 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.
  • scripts discussed at Advanced Matlab Workshop (Aug. 18, 2011)

PHIPS Image Classifier using MATLAB

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:

  1. File → Preferences → Editor/Debugger → Language
  2. Uncheck the 'Autowrap comments' box

(Dan Ariaansen via http://www.mathworks.com/matlabcentral/newsreader/view_thread/236138, 06-09-09)

Matlab Research Licenses

The UND Atmospheric Sciences Department has floating research licenses that allow installation of Matlab on your research computer. Contact Gretchen for more information.

The UND CRC also has some licenses: these licenses include more toolboxes, including the Parallel Computing Toolbox.
CRC License Information

Google Earth Toolbox

Google Earth Toolbox (I haven't tried this yet, but looks promising- Gretchen)

I have used this toolbox a lot. Works great! Come by my office and I can show you some results. - Chris Theisen

atmos/software/matlab.txt · Last modified: 2020/06/08 16:04 by 127.0.0.1