how can i save the full timestamp ID number?
3 次查看(过去 30 天)
显示 更早的评论
hi guys
i have some data which i fetch from device that samples freq, volt and power. each time i recieve a sample, ill give it a datenum ID using the matlab function "now". Then ill save the data into a .txt file. The problem is, that when i save the data, the datenum ID numbers are cuttoff, making all of them the same number. That means that when i load the data again, all of the samples has the same datenum ID number, which makes it impossible to plot the data?
here is an example of what my .txt file might look like. the 4. collumn contains the timestamp ID numbers.
49886 2.361440e+004 1.339829e+003 7.348937e+005
49886 2.361004e+004 1.339829e+003 7.348937e+005
49897 2.358127e+004 1.337393e+003 7.348937e+005
49921 2.360107e+004 1.337393e+003 7.348937e+005
49928 2.359396e+004 1.337393e+003 7.348937e+005
49931 2.357588e+004 1.337393e+003 7.348937e+005
49938 2.356435e+004 1.334957e+003 7.348937e+005
Does anybody know how i can save the full timestamp ID number?
2 个评论
采纳的回答
Walter Roberson
2012-1-25
If you use dlmwrite() then you can use the Precision argument to specify a format to write with, such as '%.16e'
0 个评论
更多回答(1 个)
Walter Roberson
2012-1-25
You missed the '%' before the final 6u.
The %u format is for unsigned integers (in base 10.) When you use it to output a number which is not sufficiently close to an integer, then according to the fprintf() documentation,
If you specify a conversion that does not fit the data, such as a string conversion for a numeric value, MATLAB overrides the specified conversion, and uses %e.
It appears to me that a %.9f format would be consistent with the values for now() that are printed if you have
format long g
in effect. However, as best I calculate at the moment, millisecond resolution can be achieved with %.8f format.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!