MATLAB functions that export values into a .CSV file are very slow. It is said, that their inefficiency is rooted in bad implementation of the string concatenation. It is refered as Schlemiel the Painter’s algorithm.
Nevertheless, sometimes I have to write huge amounts of text data into CSV files. For example I had to generate test signals for power quality measurements algoritms, such as Flicker estimation.
So I had written a MEX function to speed up this task. Write process can also be interrupted by pressing
Ctrl-C using this wonderful trick (http://www.caam.rice.edu/~wy1/links/mex_ctrl_c_trick/).
Function takes four parameters
1 2 3 4 5 6 7 8 9 10
You can find the code and compiled
mexw64 for function
As you can notice difference in speed is huge! On big files ~ 1GB in size, write speed values are about 17-18 Megabytes/s.
You can use it freely, I hope it will save you a lot of time.