Dealing with input and output in Matlab
The only thing that I see is that the files are not closed with fclose after the data is read/written.  Especially using the same variable (fileID) as the file handle for the second while the first is still open (effectively losing the first one). Although you can still always do fclose('all') and I think it would close even those files still open that don't have a handle still assigned.