Csvwrite with numbers larger than 7 digits

2020-03-20 09:24发布

So, I have a file that's designed to parse through a rather large csv file to weed out a handful of data points. Three of the values (out of 400,000+) within the file is listed below:

Vehicle_ID  Frame_ID    Tot_Frames  Epoch_ms    Local_X
2           29          1707        1163033200  8.695
2           30          1707        1163033300  7.957
2           31          1707        1163033400  7.335

What I'm trying to do here is to take previously filtered data points like this and plug it into another csv file using csvwrite. However, csvread will only take in the Epoch_ms in double precision, storing the value as 1.1630e+09, which is sufficient for reading, as it does maintain the original value of the number for use in MATLAB operations.

However, during csvwrite, that precision is lost, and each data point is written as 1.1630e9.

How do I get csvwrite to handle the number with greater precision?

1条回答
▲ chillily
2楼-- · 2020-03-20 10:14

Use dlmwrite with a precision argument, such as %i. The default delimiter is a comma, just like a CSV file.

dlmwrite(filename, data, 'precision', '%i')
查看更多
登录 后发表回答