Matching Time from 2 files/arrays
Mostrar comentarios más antiguos
There are basically 2 different ways I'm trying to solve the same problem. I have 2 time fields that are both cells (i.e. yyyy/MM/dd HH:mm:ss.ff) and I want to index/find where they match. Cell array 1 has 600 records, cell array 2 has 140 (almost a 0.25 frequency difference), so only 140 matches should actually come out.
Is there a way to match them based on not EXACT matches, but at least a threshold, say within +/- 0.5 seconds?
Also, the time is not the same in each array. Do I need to ensure the format matches before intersecting, or is there a function that doesn't care the string form?
I'm trying to do this via datastore, using the time TABLES, and also via normal matrices, where time is CELL ARRAYS.
8 comentarios
Bob Thompson
el 1 de Feb. de 2019
What about storing the data in a datetime format?
Tom W
el 1 de Feb. de 2019
Tom W
el 1 de Feb. de 2019
Bob Thompson
el 1 de Feb. de 2019
Not necessarily, I mostly mean that instead of storing the time as a cell, string, or table value, that you convert the class to a datetime format.
time = datetime(timearray{1});
If you give an example of how your data is stored I might be able to help in greater detail.
Bob Thompson
el 1 de Feb. de 2019
What exactly do you mean by 'serial' time? Perhaps we're talking past each other about the same thing.
Tom W
el 1 de Feb. de 2019
Bob Thompson
el 1 de Feb. de 2019
Editada: Bob Thompson
el 1 de Feb. de 2019
It is possible to specify the precision of the input to contain millisecond values, I would suggest reading over the documentation of datetime to find exactly which format you need.
With the values in datetime format you can generally just treat them as normal arrays, although conducting a subtraction of values will give a duration array.
I apologize if I'm not being very helpful, I don't normally work with full dates, just time values in seconds.
Bob Thompson
el 1 de Feb. de 2019
Doing some further searching it seems that using datetime limits arithmatic precision to seconds. If you are ok with having a 1 second precision then I would suggest you keep working with this format. But if you really need the ms precision then you will likely need to end up treating the values as strings, and using regexp to break it apart, or to convert the strings into numeric arrays, where each column represents a different time rank (year, month, day, ...).
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Time Series Objects en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!