Matlab Programming (Psych 114M)

Instructor: Mark Steyvers (
Office hours: Friday 3-3:50pm (SBSG2316)

Teaching Assistants:
Irina Danileiko (
Kier Groulx (

Optional Discussion/Lab Section: Wed 3:30-4:20pm SBSG240 (Led by TAs)

Course Summary:  this course is designed as a first-course in programming using Matlab as the primary language.  The course will provide a background in the rudiments of programming, including syntax, program control, input/output management, debugging techniques and graphics. During the course, we consider applications to problems encountered in the social sciences such as data visualization, data analysis, and stimulus generation.

Syllabus: information for students

Screen casts: a basic Matlab introduction is given in a number of screen casts available through UCI replay as well as YouTube (see this playlist).

Textbook:  Matlab for Psychologists (2012), Borgo, M., Soranzo, A., Grassi, M. Available online for free as an e-book. This might not work outside of the UCI network (click on free preview): You can also try this direct link:

Tutorials: you also might find it useful to look at various tutorials on the web:

Help within Matlab program:
type in Doc in command window to bring up documentation and a "getting started" guide

Matlab Software: the classroom computers have Matlab installed. Having your own laptop computer with Matlab installed allows you to continue to work outside the classroom -- helpful, but certainly not required. A free student version of Matlab apparently is available by following these instructions:

Required Material & Assignments

Lesson Concepts Reference Material Screencasts Assignments
  • User Interface
  • Matlab as a calculator
  • Variables
  • Matrices
  • Chapter 1: basic operations
    Skip "A brick for an experiment". Note: The book has an error on page 9. There are 3 matrices shown. The one on the far left is not labeled correctly. It is a 4x3 matrix, not a 3x4 matrix.


  • Note: you can take the EEE quizzes only once -- make sure you have gone through all the material in this section 
  • Logical Indexing and Operators
  • Strings
  • Keyboard input
  • NaN
  • Structures
  • Cell arrays
  • Import/Export
  • Chapter 2: data handling
    Skip: dynamic field names
    Skip: "A brick for an experiment"


  • Basic plots
  • Customizing plots
  • Multiple graphs
  • Graphics handles
  • Chapter 3: plotting
    Skip: "A brick for an experiment"
  • m-scripts and functions
  • Control flow
  • For loops
  • While loops
  • Breaking loops
  • Try/catch
  • Functions
  • Scope of variables
  • Chapter 4: Programming concepts
    Up to page 87 excluding "Change the number of inputs and outputs"


  • Import/export
  • Good programming style



  • Random numbers
  • Random permutations
  • Sound / Images
  • Exporting data
  • Dates and times
  • Random numbers (11 min)
  • Loading/saving Matlab data (10 min)
  • Matlab programming style (6 min)


  • Loading data
  • Data analysis
  • Read parts of Ch. 7
  • Matlab documentation of the dir function
  • Subfunctions
  • Nested loops
  • Debugging



Optional Assignments

Lesson Concepts Reference Material / Data Assignments
  • Graphical User Interfaces
  • Callback functions
  • Chapter 8: The Charm of Graphical User Interfaces
  • Section 13.4 of "Matlab: a practical approach" book
  • Matlab documentation on uicontrol
  • PsychToolbox
  • Chapter 9: PsychToolbox (video)
  • Chapter 10: PsychToolbox (Sound, Keyboard and Mouse)
  • Example program "bounce.m" that demonstrates how to set up a field of moving ovals. You can use this program as a basis for your own program.
  • Example video that shows how the Motion Tracking Task could like (flash mp4)
  • Basic illustration of the MOT task
  • More demonstrations and background reading of the MOT task
  • PsychToolbox