I have a large matrix (2e6 x 3) which I have to write to a text file.
dlmwrite takes about 230s to achieve this task.
From your experience what is the fastest way to write a large matrix to a text file?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The following applies to MATLAB, but I suggest you try it in Octave. First of all, if you can – transpose the matrix. Here are examples using
fprintfandcsvwrite(essentiallydlmwrite)If not transposed, it will take ages indeed. By default,
fprintfflushes the buffer after every call. You can try to useWinstead ofwto open the file, but it does not improve the situation here too much.