How to perform common operations in Matlab


Using this cheatsheet

The best way to use this cheatsheet is to go through the examples and actually run them in Matlab. Doing this well help you to see what the code actually does.


Defining variables

Download defining_variables.m

Constructing matrices

Download constructing_matrices.m

Subsetting matrices

Download subsetting_matrices.m

Subsetting cell arrays

Download subsetting_cellarrays.m

Logical operations (numbers)

Download logic_numbers.m

Logical operations (strings / chars)

Download logic_strings.m


Download loops.m

Applying functions to arrays

Download applying_functions.m

Flow control

Download flowcontrol.m

Declaring functions

Download my_func.m

Download my_func2.m

Simple plotting

Download simple_plots.m

Concatenating variables

Download concatenating_variables.m

Specifying colours (PsychToolbox)

Download psychtoolbox_colour.m