How to get the full precision on timestamp after using canSignalImport?

10 次查看(过去 30 天)
When I get the timetable from the result of canSignalImport function, I got the timetable with limited precision of timestamp although the input '.ASC' file is having more detailed precision of the timestamp.
For example, the input '.ASC' file is having number of '6321.869787', but the actual result on the timetable is '6321.9.'
However, I can see more precision on the result of canMessageImport function.
>> outMsgImport(1)
ans =
Message with properties:
Message Identification
ProtocolMode: 'CAN'
ID: 272
Extended: 0
Name: 'XXXXXXXX'
Data Details
Timestamp: 6.3219e+03
Data: [240 0 0 0 0 0 0 240]
Signals: [1×1 struct]
Length: 8
Protocol Flags
Error: 0
Remote: 0
Other Information
Database: [1×1 can.Database]
UserData: []
Is there anyway to create the timetable with more detailed precision in the timestamp?
Also, when I tried to change the output precision format to 'long' by using 'format long' command, I can see some more digits on the timetable from canSignalImport function. Is this the only solution?

回答(1 个)

Animesh
Animesh 2023-6-19
I understand that you need more precision in your timestamp value, long format is one way to do it and it gives a precision of 15 digits after the decimal.
You can also use datetime function instead which converts your timestamp to datetime object, which have higher precision than their numeric counterpart.
time = datetime(timetable_data.Timestamp, 'ConvertFrom', 'datenum');
Note that, unlike the "format long" method, which only affects the display of the data, creating datetime objects maintains the actual precision of data.
You can refer the following documentation for more details:

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by