MATLAB is full of all kinds of shortcuts and neat ways of doing things, but it can take a long time to discover them on your own. And, sometimes you discover something but don’t realize at the time that you need it or how it will fit into your workflow or project. Wouldn’t it be nice to have a list of these things to look at and refer to periodically?!
Over the years, I’ve compiled a list of little things, pieces of advice, that I’ve passed on to my students. I’ll be following up on this post with a series of posts in which I explain a little bit about each of the following tips:
- Comment, comment, comment!
- Minimize # of variables in workspace
- Avoid for loops, if possible
- Use a “flag” variable for filtering
- Don’t use punctuation or spaces in variable names
- Code “folding” - when you just don’t want to see your code!
- Run code in sections - sometimes you just want to run part of your script
- Cell arrays - arrays of anything!
- Structures - it’s all about the dot
- Tables/timetables - data references with names
A lot of these are just variable types that you may not have come across yet, especially if you’ve recently started using MATLAB. Others are just simple but very useful features that may have been hiding in plain sight!