Category: Matlab examples
-
Log determinant of positive definite matrices in Matlab
In Bayesian data analysis, the log determinant of symmetric positive definite matrices often pops up as a normalizing constant in MAP estimates with multivariate Gaussians (ie, chapter 27 of Mackay). Oftentimes, the determinant of A will evaluate as infinite in Matlab although the log det is finite, so one can’t use log(det(A)). However, we know…
-
Getting the steerable pyramid toolbox to work in Matlab 2008a
For whatever reason, Matlab 2008a doesn’t like the mex files that come with the steerable pyramid toolbox. If you try to recompile the mex files with Matlab’s built-in compiler, you will find that it crashes whenever you call buildSpyr. You can do the following to get it to work: Install Visual C++ express edition. Restart…
-
Fast data smoothing using a running average
In the lab, we preprocess eye position data using a running average. We previously used the matlab smooth function, with the ‘moving’ argument. This matlab function implements very generic data smoothing, and is therefore unoptimized and slow. You can download a better running average function from matlab central called runmean. For a window size of…
-
Binning in matlab: a one-liner
Sometimes a stimulus or response in an experiment is sampled at a uselessly high frequency. For example, a 3d (x, y and t axes) stimulus for a psychophysical reverse correlation experiment might include one noise sample per time frame. If a trial lasts a second, that can mean 100 samples or more, and if the…
-
Using command line programs in matlab: disable screen saver during an experiment
PsychToolbox doesn’t have a function to enable or disable the Windows screensaver, and the screensaver popping seems to crash PsychToolbox. Matlab allows you to run dos programs from the command line, so a quick way to solve this issue is to grab the command line app FlipSS, put it in your experiment directory, and then…