Introductory resources to learn programming
There are some very good free on-line tutorials out there to help you begin to learn the basics of pretty much any computer language.
-
A nice introduction to Matlab programming can be found here.
-
Mathworks, the company that provides Matlab, has an extensive set of help and reference pages. See this page to start. Of these introductory modules, psychologists will likely find the following most helpful:
-
Getting a comprehensive book for learning can also be helpful. There are many, many commands and functions that have already been written and shared that can make your life easier, but remembering their details is not always easy.
|
Ticking off the boxes: Basic knowledge you should have
To go through the rest of the modules contained on this site, you should make sure you understand the following:
-
Understand the most common data and variable types used in Matlab:
-
Understand how commands are written and executed.
-
Understand logical operations and their usage. This includes testing for equivalence (==, ~=), comparison (>, >=, <, <=), and multiple conditions (&, |). Learn about functions for comparing strings (e.g., isequal, strcmp, strcmpi)
-
Understand how to control the order and flow of command execution
-
Understand scripts and functions as well as the difference between them
-
Understand the value and strategic use of comments (non-executable code that allows you to state, in English, what code is doing, to provide guides for more readable code)
-
Understand file access and how to read and import different kinds of data
-
Understand how to use the debugging tools, using both the GUI and command-line functions like dbstop.
-
Understand regular expressions and how to use them. Regular expressions can be incredibly helpful for finding full or partial text matches in data, and for replacing one set of text with another.
More advanced programming knowledge
None of the code presented in these pages requires the knowledge below. However, as you progress through coding skills, you may find these aspects of coding extremely helpful.
-
If you are working with large datasets or computationally intensive analyses (e.g. machine learning, modeling, etc.), learning how to use Matlab's distributed computing capabilities is a must. Otherwise, you could be looking at your first grey hairs before an analysis runs to completion (assuming you don't already have them!).
Understand the uses of the parpool/parfor combo for breaking up jobs with a huge number of loop-iterations. For example, our lab uses this functionality to reduce the time taken to estimate complex computational models.
Understand how to run multiple instances of a function simultaneously and in parallel using the createJob/createTask combo. This can be useful if you've written a script/function that runs once per subject, but takes a long time to finish all the calculations for that subject. We often use functionality like this to process subjects through a neuroimaging pipeline in parallel, or to estimate parameters of a computational model on a per-subject basis.
|