compare time series with different time steps

11 views (last 30 days)
Lei Zeng
Lei Zeng on 20 Jun 2020
Commented: Lei Zeng on 20 Jun 2020
I have 2 sets of time series data, v(t). These two data sets have different time steps. For example, t1 = 0: 0.3: 6; t2 = 0: 0.4: 6. I am wondering how I can compare the differences between two data sets, such as norm(data1-data2).
Thank you!

Answers (1)

Walter Roberson
Walter Roberson on 20 Jun 2020
You have to interpolate them to a common time.
There are a few ways you could proceed:
  1. You could choose the times from one of the signals, and interp1() the other signal at those times. Watch out for extrapolation (it typically returnes nan)
  2. You could find the overlapping time range, max(min(t1),min(t2)) to min(max(t1),max(t2)) and linspace() that and interp1() each of the signals to that common time. If you do this, it might well be the case that none of the original points from either signal are used exactly
  3. You could find the overlapping time range, max(min(t1),min(t2)) to min(max(t1),max(t2)) and find the union of all of the t1, t2 that fall in that range, and interp1() each of the signals to that union of times. If you do this, then every original point (within the time overlap) will be preserved exactly for both signals, and as well interpolation will be done for the points that exist in one but not the other

Community Treasure Hunt

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

Start Hunting!