MATLAB: Xlswrite precision problem

excelprecisionxlswrite

Hi!
I have a huge amount of data in array (60000×17) with precision of 3 decimal places. After some operations I would like to save that array in excel file by using xlswrite command. The problem is that whenever I do that the excel file become where huge because all the numbers are stored as double (15 decimal places).
So my question is how can you store an array with only 3 decimal places by using xlswrite command?
I also tried to transform numbers into single before saving but it didn't work.
thank you in advance!

Best Answer

xlswrite does not provide this option itself.
You could do the rounding in MATLAB before committing to file:
A=rand(3)
xlswrite('foo.xlsx', round(A*1e3)/1e3);
This should mostly work, but I suppose there may be cases where an exported value can be ?.???99999999999999 or some such. There may be a better numerical way to do this kind of round, but I don't know what it might be.