• ## Rewriting Matlab code in Python

So you’re beginning to use Python daily. Great! You might still have a critical set of Matlab scripts from back in the day that doesn’t have a neat equivalent in Python. How do you rewrite this code in Python without introducing many headaches? I’ve had to do this a handful of times and have developed…

• ## Transitioning away from Matlab

In my last article, I talked about how I got a job in industry. I had been programming Python on and off for 10 years when I got my first non-academic job. Having proficiency in a language that people use outside of academia will improve your chances of getting a job in industry. Learning a…

• ## 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…

• ## Fast 1D and 2D data binning in Matlab & Python

I needed a fast method of binning 1D and 2D data in Matlab – that is, to compute the mean of z conditional on x being in a given range (1d binning) or the mean z of conditional on x and y being in given ranges (2d binning). I stumbled upon a clever method using…