added matlabstuff from csf branch