Synchronizing timeseries with 'Intersection' not producing correct result

15 visualizaciones (últimos 30 días)
notfrank
notfrank el 22 de Oct. de 2018
Respondida: Steven Lord el 22 de Oct. de 2018
Hi all,
I have two timeseries, of approximately 10,000 steps. They are both an output from the same Simulink model, and therefore have the same timestep within - with a few exceptions. I can look through the data and see that the vast majority of timesteps match up. I need the time data to sync up exactly with no interpolation, so I'm using sycnhronize(t1, t2, 'Intersection'). However, this produces timeseries only 12 steps long. The 12 steps that sync are completely arbitrary and the original time series sync perfectly directly before and after them and aren't included.
I'm thinking it may be a problem with one of the timeseries starting earlier than the other (t1 starts at 0 seconds and t2 starts at 2 seconds), however this hasn't been an issue with other similar timeseries.
Any ideas?
For example,
t1.Time(4310:4315)
ans =
43.0785
43.0885
43.0985
43.1085
43.1185
43.1285
t2.Time(4105:4110)
ans =
43.0785
43.0885
43.0985
43.1085
43.1185
43.1285
[t3,t4] = synchronize(t1,t2,'Intersection')
t3.Time(4:6)
ans =
17.8985
43.0985
72.1385

Respuestas (1)

Steven Lord
Steven Lord el 22 de Oct. de 2018
If I had to guess, this is probably the standard floating-point issue. Element 4310 of t1's Time vector and element 4105 of t2's Time vector appear the same, but if you subtract one from the other the stored values are probably very slightly different.
You may want to specify 'commonrange' as the newTimeBasis (the union of the row times over the intersection of the time ranges.) Alternately concatenate the time vectors manually then use uniquetol to generate the new time vector and synchronize the two timetable arrays using that new time vector with the 'nearest' method.

Categorías

Más información sobre Simulink en Help Center y File Exchange.

Productos


Versión

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by