The data is not correctly written with CSVWRITE, after 100000 rows

7 ビュー (過去 30 日間)
Caizhen
Caizhen 2014 年 6 月 26 日
回答済み: José-Luis 2014 年 6 月 26 日
I need to use the following to write the time with 10ms step for more than 1100 seconds.
csvwrite('test.csv', [1:0.01:1100]');
The data in 'test.csv' is ok, until > 1000
999.94
999.95
999.96
999.97
999.98
999.99
1000
1000
1000
1000
1000
1000.1
1000.1
1000.1
1000.1
1000.1
1000.1
1000.1
1000.1
1000.1
1000.1
1000.2
1000.2
1000.2
1000.2
Did someone have the same problem? How did you solve this?
Thanks C

回答 (2 件)

José-Luis
José-Luis 2014 年 6 月 26 日
From the documentation:
csvwrite writes a maximum of
five significant digits. If you need greater precision, use dlmwrite with a precision argument
You could use:
dlmwrite('test.csv', [1:0.01:1100, 'delimiter', ',', ...
'precision', 6)

C.J. Harris
C.J. Harris 2014 年 6 月 26 日
You could use fprintf instead.
fid = fopen('test.csv','w');
fprintf(fid,'%0.2f\n', [0:0.01:1100]);

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by