I teach a self-designed Matlab course that I refer to as "The Missing Manual." It consists of approximately 6-7 hours' worth of interactive lectures, and is intended for people who are fairly new to the software (or coding in general), as well as those who desire to step up their game. These include advanced undergrads, grad students, postdocs, and hands-on professors.
Note that there are plenty of excellent 'Intro to Matlab' textbooks out there, which teach beginners how to write code and which cover subjects such as syntax, array manipulation, 'if' statements, and 'for' loops. To avoid reinventing the wheel, my course does not cover topics that are already well-documented in manuals (as that activity is best done in the practitioner's own time and in front of the terminal).
Rather, my material forms a 'missing manual' of tips that I picked up by trial and error during my phd- a wealth of advice that I never came across in introductory textbooks, but that I would definitely have appreciated, had I received a systematic introduction to them early on. My aim is to provide an overview of the tools that are available, with an emphasis on productivity, data handling, file management, and project management; how to engage with Matlab as a 'friend' and optimize one's resources for research.
At first glance, some of these topics may seem a bit advanced, especially if you are an absolute beginner and your immediate concern is to learn how to code. Speaking from experience, I wouldn't worry too much about that- even if the nuts and bolts of implementation are beyond you right now, having a qualitative idea of what is out there will allow you to identify and pick up what you need when the time comes. Too much knowledge is accumulated painstakingly in isolation, and I want to speed up/ short-circuit this process for as many users as possible. My course will help turn some of the 'unknown unknowns' into 'known unknowns.' :)
When I first started learning to use Matlab, I relied heavily on a couple of textbooks from the library- this is a good starting point for covering the basics. As far as possible (apart from Matlab, the MS Office suite, and Adobe Illustrator), most of the tools that I use in tandem with Matlab are freely available and open source. They are also widely supported by communities of devoted users (e.g. Git, Autohotkey, Dropbox).
Topics covered:
  1. Best practices
  2. File organisation
  3. Keyboard shortcuts
  4. Save and load data using the .mat format
  5. Read and write data with Excel spreadsheets
  6. Use the powerful ‘find’ function to search through code across all files
  7. Use the code comparison tool to view code segments side by side
  8. Use cells for data arrays of varying length
  9. Use the Help function
  10. Use the Mathworks site to post and answer questions
  11. Use error handling and debugging tools
  12. Use a version control system to keep code organised; access code from multiple locations; and share code with collaborators
  13. Use Autohotkey to automate repetitive tasks
  14. Run basic statistical analyses in Matlab
  15. Generate images, including publication-quality figures- and edit them with Adobe Illustrator
  16. Use the parallel computing toolbox for large datasets and high throughput processing
  17. Other software tips (e.g. MS Word keyboard shortcuts, AutoHistory plugin)
Materials (including example code, style guidelines, tips, and topics covered during the lectures) are available here: https://github.com/axienjii/matlab_demos
  • The main document to refer to is 'matlab_class.docx,' which contains detailed tips and references to sample code.
  • Subsidiary documents are: 'Autohotkey_demos.docx,' which contains explanations of the code used in demo .ahk scripts; and
  • 'stats_demo.m,' containing a list of commonly used hypothesis tests and descriptions of how to implement them in Matlab- a PDF version is displayed below, for easy reference.
I've also uploaded PDF documents (from other authors) to this repository, which include:
  • johnson_Matlab_style_guide.pdf: A 'coding best practices' guide, which covers style guidelines.
  • MATLABWorkshop.pdf: A crash course in Matlab with examples, covering the basics.
  • MATLAB_PTB.zip: A series of short chapters covering basic topics and leading up to being able to programme for PsychToolBox.
To copy code from the Github repository, click on the icon of a clipboard (with the tooltip, 'Copy to clipboard'). If you're at a work station that does not have Matlab installed, you can download a free code editor such as Sublime Text.
If using Sublime Text:
  • Save your .m file with the extension '.matlab' instead of the usual '.m' so that the editor can parse the code correctly and use the appropriate colouring scheme.
  • To create a printable version of your code, you need to download a plugin as the basic Sublime Text software does not offer this capability (refer to http://stackoverflow.com/questions/16004842/how-do-you-print-in-sublime-text-2).
    1. Install the Package Control first and restart your editor.
    2. Install Highlight plugin.
    3. Open the Sublime Text palette, press ctrl+shift+p (Windows, Linux) or cmd+shift+p (OS X).
    4. Type and confirm: Install Package
    5. Type and confirm: Highlight or Print
    6. 'File > Print as HTML via Browser' will now allow you to generate a PDF copy.
Site map | Terms and conditions | Contact | © 2018 Chen Xing. (Last update: 10 March, 2018)