Azzera filtri
Azzera filtri

How to merge two interleaving time series?

34 visualizzazioni (ultimi 30 giorni)
I have two different data sets that were measured in interleaving in time. Ex.
Data 1: measures 2400 points and stops Data 1: 2400 again and so on..
Data 2: measures 1200 points and stops
I need to merge these signals based on their timestamp. Initially I tried concatenating the two time vectors and sorting in an ascending order and then join the signals using an if, but that didn't work.
What is the quickest way to do so? Is there any specific function that does that to me? The time vectors are in datenum format.
Many thanks!

Risposta accettata

Peter Perkins
Peter Perkins il 11 Mar 2019
Larissa, I strongly suggest that you convert those datenums to datetimes (or durations? not sure, not enough information from you) and use timetables. At that point, it's just a matter of concatenating and sorting.
That's assuming the two data sets are measuring the same thing. If they are measuring different things, then you would not want to concatenate -- you'd use synchronize instead.
  1 Commento
Larissa Perez
Larissa Perez il 12 Mar 2019
Thanks Peter! I ended up being able to do it by creating a new time vector that included all the data points and then using the function intersect.

Accedi per commentare.

Più risposte (1)

Agnish Dutta
Agnish Dutta il 26 Feb 2019
Modificato: Agnish Dutta il 26 Feb 2019
I'm assuming, you don't have any gaps in your time series data.
One way of doing this would be to put you time series data into 2 different .MAT files. Then, merge the data into a single .MAT file.
You'll obtain a .MAT file that'll look like this:
fin_MAT
Time Value1 Value2 ... Value16000
datetime1 val11 val21 ... val160001
datetime2 val22 val22 ... val160002
. . . ... .
. . . ... .
. . . ... .
datetimeX val1X val2X ... val16000X
Then, proceed to create a new time series variable from the data in the .MAT file.
fin_ts = timeseries(fin_MAT(:, 2:end), <your_time_vector>, 'name', 'xyz');
Refer to the following for more information:

Categorie

Scopri di più su Dates and Time in Help Center e File Exchange

Prodotti


Release

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by