How can I save a very large MATLAB sparse matrix to a text file?

interop, matlab

Solution

I saved it as text using Java within MATLAB. MATLAB Code:

pw=java.io.PrintWriter(java.io.FileWriter('c:\\retail.txt'));
line=num2str(0:size(data,2)-1);
pw.println(line);
for index=1:length(data)
    disp(index);
    line=num2str(full(data(index,:)));
    pw.println(line);
end
pw.flush();
pw.close();

Here `data` is an extremely large sparse matrix.

Problem

I have a 30000x14000 sparse matrix in MATLAB (version 7), which I need to use in another program. Calling save won't write this as ASCII (not supported). Calling `full()` on this monster results in an `Out of Memory` error. How do I export it?

Original source