writematrix as the recommended alternative to dlmwrite from R2019a

81 views (last 30 days)
Hello,
I recently moved to Excel 2016 and Matlab R2019a and saw a significant increase in the size of the csv written by dlmwrite.
I also saw that dlmwrite was not recomended starting from R2019a and the suggested alternative was writematrix.
writematrix does not offer all the flexibility of dlmwrite, such as row and columns offsets as well as precision.
Is there any workarounds to still be able to use row and columns offsets with writematrix ?
  5 Comments
Mehdi Hacini
Mehdi Hacini on 19 Aug 2019
Thanks both for your answers.
Somehow windows 7 with excel 2010 was managing the precision 100 and removing anything unecessary which is not the case anymore leading to the increase in size. After reducing the precision to 16 everything is back to normal and i will stick with dlmwrite for the row and col offsets.
dpb
dpb on 19 Aug 2019
I think Win7 vis a vis 10 had nothing to do with the symptoms and certainly as Guillaume notes Excel has nothing to do with dlmwrite and vice versa. I think the '100' as the precision argument had to be an accidental introduction that wasn't present in the compared-to cases when those files were created.

Sign in to comment.

Accepted Answer

Guillaume
Guillaume on 19 Aug 2019
The documentation of writematrix does say that it writes numbers using the longG fomat. longG format is 15 digits of precision (for double), which is about as much precision you can get from double numbers. Using more precision than that is pointless, and going to 100 is completely absurb as dpb said.
So. there's no point trying to be more precise than what writematrix does. If you want to be less precise, there's indeed no way to do that, so you'll have to use dlmwrite.
Similarly,if you want to write into an existing file, you'll also have to use dlmwrite.
For the typical use case, writematrix is a direct replacement. It doesn't mean you have to replace it.
Once again, for csv files, excel is completely irrelevant.

More Answers (0)

Products


Release

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!