Tutorial 2. MATLAB Programming

Tutorial Overview

Sequence of four images of a coin, with progressively less detail and resolution. One MATLAB® tutorial exercise explores how the retinal image (upper left) is processed by neurons in the early stages of the visual pathway. This processing can be modeled as convolution with spatial filters that incorporate Gaussian smoothing (upper right). The result of retinal processing can be described as convolution with the difference of two Gaussians that form a center-surround spatial structure (lower left). The spatial receptive fields of neurons in visual cortex can be described as an oriented Gabor filter, producing results such as that shown for an oblique orientation in the lower right.

MATLAB is a powerful technical computing environment that is used extensively in the research described in this course. MATLAB programs are used, for example, to conduct experiments and gather data, analyze and visualize data, and implement computational models. This tutorial is intended for students who already have computer programming background and want to learn some of the basic elements of the MATLAB language and how it can be applied to sample problems in computational neuroscience.

Unit Activities

NOTE: There are no videos for this tutorial.

Useful Background

  • Introduction to computer programming, linear algebra
  • The MATLAB technical computing environment can be purchased from MathWorks, Inc.
  • The free GNU Octave Scientific Programming Language is largely compatible with MATLAB and can be used to run the MATLAB examples in this tutorial.

MATLAB Introduction

  • The tutorial document below, which was originally prepared by Mark Goldman (UC Davis) and extended by Daniel Zysman (MIT), provides an introduction to aspects of MATLAB that are used in the programming exercises provided in this tutorial.
MATLAB: Goldman / Zysman Introductory Tutorial (PDF)

Code + data files for these tutorial examples (ZIP) (This ZIP file contains: 8 .m files and 1 .mat file)

Some additional resources for learning MATLAB are listed in the section on Future Study. You can also view a 5-minute video introduction to MATLAB by entering the following expression in the MATLAB Command window:

playbackdemo('GettingStartedwithMATLAB', 'toolbox/matlab/demos/html')

MATLAB Programming Exercises

The table below provides descriptions of programming exercises, supporting code and data files, and solution code. They were prepared by Daniel Zysman and Ellen Hildreth, based on some material from the 2014 summer course originally developed by Emily Mackevicius.

EXERCISES SOLUTIONS 
Feedforward neural networks for digital character recognition (ZIP - 2.3MB) (This ZIP file contains: 1 .doc file and 1 .mat file) Solutions (ZIP) (This ZIP file contains: 2 .m files)
Spatial processing in the visual pathway (PDF) Solutions (ZIP) (This ZIP file contains: 4 .m files)
Integrate and fire model of neural activation (PDF) Solutions (ZIP) (This ZIP file contains: 6 .m files)
Spike-triggered averaging of neural responses: Handout and data (ZIP - 2.1MB) (This ZIP file contains: 1 .doc file and 1 .mat file) Solutions (ZIP - 1.9MB) (This ZIP file contains: 2 .m files and 1 .mat file)

Further Study

Attaway, S. MATLAB: A Practical Introduction to Programming and Problem Solving. Butterworth-Heinemann, 2013. ISBN: 9780124058767. [Preview with Google Books]

Buy at MIT Press Cohen, M. X. MATLAB for Brain and Cognitive Scientists. MIT Press, 2017. ISBN: 9780262035828.

Gilat, A. MATLAB: An Introduction with Applications, Fifth Edition. Wiley, 2014. ISBN: 9781118629864.

Goldman, M. Tutorials in Computational Neuroscience.

Gore, J., P. Blainey, E. S. Lander, E. Fraenkel, M. E. Wiltrout, N. Schafheimer. Quantitative Biology Workshop. Self-paced online course from MITx on edX.

Hanselman, D. C., and B. L. Littlefield. Mastering MATLAB. Pearson, 2012. ISBN: 9780136013303.

Mathworks, Inc. MATLAB tutorials, including MATLAB Onramp, and MATLAB documentation, including a This resource may not render correctly in a screen reader.MATLAB Primer (PDF - 2.4MB).

Šćepanović, Danilo. 6.094 Introduction to MATLAB, January 2010. MIT OpenCourseWare.

Science Education Resource Center, Carleton College. Teaching Computation in the Sciences.

Springer, M., and R. Born. Boot Camp in Quantitative Methods, based on the course Neurobiology 306qc: Quantitative Methods for Biologists taught at Harvard University.

Wallisch, P., M. Lusignan, et al. MATLAB for Neuroscientists: An Introduction to Scientific Computing in MATLAB, Second Edition. Academic Press, 2008. ISBN: 9780123745514.