Obscure Matlab features #4 – Writing help

Keeping code undocumented now might save you a few minutes, but it will undoubtedly cause you pain and misery when you do revisions 6 months from now. As you surely know, Matlab’s built-in help function parses comments immediately following the function byline and outputs these comments in the command window. It has a couple of … More Obscure Matlab features #4 – Writing help

Obscure Matlab features #3: progress reports with publish

Neurophysiology experiments can generate tons of data. In the initial stages of a project, you can easily become overwhelmed with the results of preliminary analyses. It’s a good idea to collect together the results of these analyses into a single document. This can make it easier to peruse the results with others in your lab, … More Obscure Matlab features #3: progress reports with publish

The joy of object-oriented programming in Matlab

Matlab has had support for full object oriented programming (OOP) since 2008a. Those with an OOP background (say, in Java, C# or Python) will find Matlab’s OOP features to be fairly complete. These include: Pass-by-reference semantics via subclassing the handle class Instance methods and static methods Full selection of access control for methods, properties (public, … More The joy of object-oriented programming in Matlab

Coarse-grained parallelism in Matlab with parfor

Previously, I discussed how you can take advantage of multiple cores in C. In day-to-day research, however, it’s more common to work with high-level languages like Matlab and Python. Although Matlab has been multithreaded for several years now, it’s not very good at maximally using all the cores in a computer. You can verify this … More Coarse-grained parallelism in Matlab with parfor

Obscure Matlab features #2: linear indexing, sub2ind, ind2sub

Matlab supports 3 forms of indexing matrices. There is the familiar range indexing that selects a submatrix within a larger matrix: This is also called sub-indexing. There is also logical indexing: These two methods are fairly expressive, yet there are a certain number of operations which are awkward or impossible to perform with these. Let’s … More Obscure Matlab features #2: linear indexing, sub2ind, ind2sub