add function to generate .mat files