Matlab Code
Here you will find a few Matlab code examples I have come up with over the years. They vary from simple utilities to full experiments. I hope you find them useful. If you find any bugs in these programs, please let me know: ccollin@is.dal.ca
--Charles A. Collin.
System Requirements
All of my scripts and functions are designed to work on Matlab 5.2 for Mac OS 9.x. They should also work with some earlier versions of MacOS. They seem to work fine running in the OS9 environment under OS X as well, although I have not used them extensively in this way. The experiments require the free Psychophysics Toolbox, and some functions may require the Image Processing Toolbox from The Mathworks.
Experiments
Spatial Frequency and Categorization Level
This is a complete experiment examining the effects of two factors on name-object matching: 1) Spatial Frequency and 2) Categorization level. Both factors have three levels. It would be a simple matter to replace the stimulus files if one wanted to examine other factors in the same design. The main file is sfcatlevel.m.
Three-level Global-Local Interference (coming soon!)
This is a complete experiment (actually two experiments, but they're very similar) examining the effects of interference from irrelevant information in a Navon-type global-local task, but with three levels of hierarchical structure instead of two. Included are subroutines for generating large block letters and other forms. The main files are GloLocTripleIdentity.m and GloLocTripleDirection.m.
Stimulus Generators
ShapeFamily.m
(http://www.dal.ca/~mcmullen/ShapeFamily.m)
This program generates random polygons in accordance with algorithms first set out by Attneave (Attneave, 1957; Attneave & Arnoult, 1956). It also generates families of similar polygons based on a prototype. See Collin and McMullen (2002) for a detailed description of how to use the program.
HFN.m
(http://www.dal.ca/~mcmullen/HFN.m)
This program generates the Heterochromatic Fusion Nystagmus (HFN) stimulus. HFN is a method for determining isoluminance matches between hues using reflexive eye movements (i.e., Optokinetic Nystagmus, OKN) as feedback. For more information on the stimulus, see Chaudhuri and Albright (1990, 1992) and Collin & Chaudhuri (1998). For a detailed description of the stimulus, see Collin and Chaudhuri, 2003.
Utilities, Tips, and Miscellaneous
ca.m
This "Clear All" function is a trivial yet vital little utility for closing all open psychtoolbox windows. Novice psychtoolbox users often believe their program has crashed the machine when in fact all they've done is cover up the usual desktop with a blank window. If your psychtoolbox program stops working, try hitting apple-0, then type "ca <enter>". This will clear all windows and get you back to the Matlab command window (usually).
Matpong.m
This program allows 1 or 2 players to compete in video tennis, a.k.a., "pong". Not directly related to research, but it does show off some of the Psychtoolbox's features.
Other Resources
Here are some handy links to resources I have found useful in learning to program in Matlab using the psychtoolbox.
Psychtoolbox.org
(http:www.psychtoolbox.org)
I cannot recommend the Psychophysics Toolbox enough. Get it, love it, and join the mailing list. For programming psychological experiments, it is the best, offering rapid programming and yet good low-level control of the machine.
Psychtoolbox Intro Lesson Plan
(http://www-psy.ucsd.edu/%7Eifine/MatClassAll.pdf)
This is a set of class notes for introducing Matlab and the Psychtoolbox. Very handy for those just starting out. Also available in Word format.
Various Matlab Tips & Tricks
(http://www.ee.columbia.edu/~marios/matlab/matlab_tricks.html)
This webpage contains a number of links to tips & tricks for programming in Matlab. Very handy!
comp.soft-sys.matlab
(news:comp.soft-sys.matlab)
This newsgroup is extremely useful, and newbie friendly.