Is streamlined to be faster and writes the output matrix to a mat-file after each iteration so if the process crashes the data can still be looked at.  This slows down the process but is not the rate determining step and prevents the frustration fo running a code for hours only to have no data at the end