Two Data Sets, one with Milliseconds in "1111" format (no periods etc.), other one with seconds in 1.111 (with period delim.), can I make them the same?
1 view (last 30 days)
Show older comments
Hi,
I collected data and have two different documents. One has time in the format of milliseconds with out any punctuation. For example:
1553
1566
1580
1593
1606
the other matrix has its time in seconds and with punctuation, for example:
0.0800000000000000
0.100000000000000
0.120000000000000
0.140000000000000
Besides *1000 or /1000 to get them into the same unit, I am struggeling making them the same format. Can this be done or do I have to collect the data again?
Thanks for any help.
A.
2 Comments
Walter Roberson
on 20 Jan 2023
0.120000000000000
is it possible for any of those values to be greater than 1? Representing more than 1000 milliseconds?
You show 1553 milliseconds as an example, which would be 1.553 seconds, whereas your 0.140 and so on examples are all less than 1.
If the rule were that if the value is not an integer then it must be seconds and fractions of a second, then you would run the risk that (for example) exactly 1000 milliseconds might appear having been encoded as 1.000 but a rule checking fraction part would see no fraction there and figure that perhaps it just happened to be 1 millisecond.
Do you have the numbers grouped at the file level, before putting them all in a common place? If so then you could check whether any row had a fraction part and if so assume seconds + fraction
Answers (1)
Animesh
on 8 Mar 2023
Hello,
Yes, you can convert the two data sets to the same format in MATLAB. Here is an example:
Assuming you have the two data sets in variables data1 and data2, where data1 contains time values in milliseconds without any punctuation, and data2 contains time values in seconds with punctuation, you can convert them to the same format by dividing data1 by 1000 to convert milliseconds to seconds. Then, you can compare the resulting strings with the values in data2.
0 Comments
See Also
Categories
Find more on MATLAB Support Package for Arduino Hardware in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!