My favorite obscure and/or tricky MATLAB stuff:
- Beware of negative zero! (I blogged about this here too.)
- Bizarre end semantics.
- Super efficient N-D Cartesian product. Explained nicely by Luis Mendo (give that man a vote!).
- Dynamic legend.
- The colon operator can be passed as a character! Like this, x(':',end).
- colon is smart! The syntax j:i:k does not always create an array that goes to k; it goes to j+m*i, where m = fix((k-j)/i);.
- sprintfc: print into a cell array.
- The for loop expression (for var = expr ...) can be a matrix, looping through columns.
- Most operators have named functional forms.
- Set membership tests for sorted arrays: ismembc, ismembc2, and more.
- You can make a DllMain for a MEX file to implement attach/detach instructions, and mexAtExit for module unload ops.
- How does dynamic array resizing/growth (possibly) work?
- Where does guidata "hide" the handles structure (and other GUI data tricks)?.
- Changing the order of line series colors (ColorOrder), and the "best" colors.
- What does MATLAB do internally when you truncate an array with Z(end-N:end)=[];?
- Why don't they add 0 based indexing to MATLAB (according to Cleve Moler)?
- Apparently MathWorks did not expect anyone to actually overload curly braces ({}).
- accumarray rocks, but you have to use it right.
- The default C MEX configuration uses ANSI C, which really stinks. Enable C99. This one irritates me because people pretend like they can't just TURN IT ON!
- bsxfun can replicate in multiple dimensions.
- Use kron to replicate either array elements or whole arrays.
----------
My profile footer was usually something like this:
I'm a research scientist focused on medical image processing, machine learning, dimensionality reduction, and parallel computing. I ♥ `accumarray`.
4 comments:
Hey, thanks for that! :-)
Of course, it's a great Q&A! Also, I think perhaps it got a little "Transpose blog bump". Haha, yeah right. I might want to start posting again some day for that to be possible.
Aww... where is your advice to **never use length**? Someone that I helped tried using this and they had the impression that this would *always* find the total number of rows. I tried linking them to your infamous "never use length ever" quote, but it's gone :( BTW, we all at SO miss you!
BTW, here's that question/comment :) http://stackoverflow.com/questions/34094563/matlab-continue-function-skips-the-wrong-interation#comment55967314_34094563
Post a Comment