Materials and exercises from the Introduction to Matlab Programming course which forms part of our MSc Cognitive Neuroscience.
For viewing the materials use: https://schluppeck.github.io/learningMatlab/
For inspecting the code and details: https://github.com/schluppeck/learningMatlab
☑️ Create a (free) account at The Mathworks. Using your university e-mail address will allow you to use the university's academic license. As an added bonus, you'll be able to install Matlab on your own computer / laptop (MacOS, Windows, or Linux)
There is a self-directed Matlab onramp course that we will refer to during the course. This includes some short videos and interactive lessons, which we will use to flip the classroom.
☑️ We'll ask you to complete this onramp course. The sections should't take too long complete and there are lots of hints to guide you through the material at your own pace.
Get me started on the material here!
The first place to check out is the aToZ-intro. Run through these exercises on the lab machines (or on your own copy of Matlab).
Find PDF materials in one place in the matlab primer [PDF]
Lecture slides for sessions 1-4:
Who is it for? What are the aims?
The main aims is to help the students to get to grips with the basic ideas of computer programming and, more specifically, the use of Matlab. The course materials started out for a graduate course for psychologists and neuroscientists.
The exercises draw on material that students on our MSc courses encounter in other modules. It's therefore a great opportunity for hands-on revision of some important concepts such as
- time series data
- images in 2d and 3d
- linear/non-linear regression
The syllabus is for a 10 week (10 x 2h) lab class, assuming very little computer experience (or maths) at the start.
Feel free to use the code. If you feel it's particularly helpful to you... I accept donations in the form of freshly roasted coffee beans.
The course has two chunks. (Schluppeck has been tinkering with the course more recently and we've also done a different project around stimulus presentation.
an introduction to the basic ideas (variables, functions, control flow) - running over the first 4 weeks. Check out the material in the aToZ-intro folder and the associated readme file here.
Timetable A. A project, building some basic utilities / functions for looking at neuroimaging data and performing linear regression (GLM), 6 weeks. Details on the imaging-related units is outlined in here.
Timetable A (around a looking at images, 3d data, ...)
|What is Matlab, the environment, variables, indexing, ...
|Types of data: numeric, logical, text, etc.
|Indexing, looping, branching, functions, ...
|Understanding someone else's code
|What are images? How to display them
|Building / fixing up a simple image viewer
|A function that constructs a simple design matrix
|Hands-on linear regression (using a sample timecourse)
|Doing regression stats, displaying
How to get these materials
Assuming you are on a Mac: open up a
Terminal (double-click /Applications/Utilities/Terminal). Then do the following:
# if you don't already have one: create a ``matlab`` directory in your home space (``~``), then change directory to it:
# get MGL (for the behavioral project)
git clone https://github.com/justingardner/mgl.git
# get these tutorials
git clone https://github.com/schluppeck/learningMatlab.git
You'll need to add both these subfolders to your path; then you should be good to go. A convenient way to do this is to run this or add this to your
To make sure you have any updates to this material, open a Terminal, change directory to the
learningMatlab folder and issue
git pull. This will sync you the material on github. Alternatively, download the zip archive of the repository.
getting started with examples - a collection of beginner friendly examples in the Matlab documentation.
The sections should't take too long complete.
getting a certificate of your Matlab ONRAMP course progress / completion"
In the 2015/2016 iteration of the course, I modified the hands-on project for building a simple behavioural task to use mgl (https://github.com/justingardner/mgl). Although this requires teaching a couple more details on how stimuli are being displayed by the OpenGL machinery and it's not pure Matlab, it's (a) more realistic and (b) makes displaying different kinds of stimuli, obtaining keyboard responses, etc. much more fun and doable.
In the 2017 iteration, students built a psychophysical experiment (slightly different task, but similar in spirit)
In 2018, the assignment for the course was complete and extend an analysis script for fMRI data by writing some helper functions. Students were also using
publish()to explore documentation and mixing code with report writing.
Denis (2024). learningMatlab (https://github.com/schluppeck/learningMatlab/releases/tag/v1.0.0), GitHub. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!