Why is there loss of precision when writing values using CSVWRITE in MATLAB 7.0 (R14)?
조회 수: 55 (최근 30일)
이전 댓글 표시
I execute the following code to write the value '1.23456789' to my CSV-file, as follows:
csvwrite('filename.csv', [1.23456789])
Upon reading the value back from the file, I see that there is some loss in precision:
val = csvread('filename.csv')
val =
1.2346
When I open the "filename.csv" file, it too contains the rounded-off value.
채택된 답변
MathWorks Support Team
2009년 6월 27일
The CSVWRITE function converts numbers to short format before writing them to the file. To preserve precision, use the DLMWRITE function to explicitly set the precision of the data in the CSV-file:
dlmwrite('filename.csv', [1.23456789], 'delimiter', ',', 'precision', 9);
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Text Files에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!