Programming


Saving from inside a parfor loop in Matlab

If you call save from a parfor loop in Matlab, like this for example: parfor k=1:100 foo = exp(-k); save(['myfile',num2str(k),'.mat'],'foo'); end it will generate an error. I have not exactly figured out why this is but probably it has to do with the fluctuating nature of the foo variable inside the parfor loop. By calling […]

The psychology of debugging - the bias of complexity

Most of the times when you are writing code you are make mistakes either in the structure or in the specific code. These mistakes become bugs that sometimes eat up a lot of time to diagnose. Once diagnosed, bugs are usually easy to fix unless there is a big structural mistake, which makes you, rewrite […]

The most awesome terminal bash command!

So Matlab has this really nice feature that if you type the start of a command in the terminal window and then press the up button you can browse through previous commands containing that text. This is a really nice feature when changing commands often. The terminal should really have this feature it would make […]

Debugging in Matlab

Getting in to someones code or just cleaning up your own Matlab code it's good to know how to do break points and other useful to make the process flow a bit smoother. I thought I would do a list of my favorites for making my code work faster and with less tedious work. The […]

Wrapper function in Matlab for plotting multidimensional functions in 3D

I have often encountered situation where I want to plot a function in 3D but it either takes multidimensional input or the function itself can't be specified over some kind of matrix multiplication. So I wrote this the other night, a wrapper function for the 3D plotting in Matlab. Basically it takes a function handle […]

Fixing the font-size for the Mathjax plugin in WordPress

Mathjax is a fantastic plugin for WordPress that renders your latex code in a wonderful way. However as with the other Latex renders the font-size can be a bit small. The CSS field on the settings page is not working for some reason, but there is a simple way to remedy that. In your theme […]