Tag: Matlab
-
Calling R from Matlab – flat file communication
I showed earlier how to fit a Bayesian hierarchical model in R to estimate experimental parameters. Our main data analysis pipeline uses Matlab, and we’d like to integrate these two environments for the purpose of analysis.So how can you pipe your data from Matlab to R and back? Flat file communication There are a variety of…
-
Fixing broken .m4v movies made in Matlab
I made a few ten-minute movies in Matlab composed of 1-second clips from BBC Earth, encoded as H.264, to use as visual stimuli. They played fine on Windows but would stop at the 170 second mark in Quicktime on Mac. We’re using Processing on Mac for visual display, which uses Quicktime in the background, so…
-
Off-the-shelf optimization functions in Matlab
Estimating a statistical model via maximum likelihood or MAP involves minimizing an error function – the negative log-likelihood or log-posterior. Generic functions built in to Matlab like fminunc and fmincon will often do the trick. There are many other free solvers available, which are often faster, or more powerful: Solvers by Mark Schmidt: there’s a huge collection of functions from Mark…
-
Load pickle files in Matlab
Updated March 2020 It’s easy enough to load .mat files in Python via the scipy.io.loadmat function. But what about loading .pickle files into Matlab? You need to do a little more work! It’s a bit roundabout, but if python is installed and on your path, you can call it from Matlab to save the data…
-
Whiten images in Matlab
Previously, I showed how to whiten a matrix in Matlab. This involves finding the inverse square root of the covariance matrix of a set of observations, which is prohibitively expensive when the observations are high-dimensional – for instance, high-resolution natural images. Thankfully, it’s possible to whiten a set of natural images approximately by multiplying the…
-
Deinterlace a movie in Matlab
Here’s a simple function to deinterlace a movie that was interlaced to go from 24fps to 30fps: