Hack code - still work in progress
We write this manually for now - but maybe we should use the MAT-file interface available in MATLAB
Document MAT file format!