Read and write matlab files