The quickest way possible to save Matlab matrices
file, matlab, performance, save
Solution
The fastest way possible is probably Matlab's save command. Alternatively, you could fwrite the whole matrix to a binary file.
Using `dlmwrite` converts the values to text, which takes time and is more data to write to disk. Don't do that unless you really need to have the data in that format. Note that `dlmwrite` will be faster if called one time with a big matrix instead of in a loop that incrementally writes your file.
Problem
I am using Matlab to invoke some external call in C++ and then receive a huge calculated matrix back. The matrix is very huge, and I do not have access to this C++ program's source code. (if I have, I will make it save from C++ right away) Right now, on my system, this C++ program only uses 1 second to calculate the given data and send back to Matlab, and Matlab's dlmwrite takes 200-300 seconds to save this single huge array on disk. I have some more thousands to compute, and I wanna cut the time down. So what is the fastest way possible to save in Matlab?