Timeseries, Timetable, timeseriescollection, Time Data Aggregation

8 次查看(过去 30 天)
When recording data in a test lab, the data channels are not always sampled at the same rate and some channels are not evenly sampled (CAN channels in Automotive Industry). MATLAB doesn't have a good construct for this other than a structure of timeseries. timetable is not better in this way. tscollection is a barely referenced and barely supported object in MATLAB that aggregates timeseries against a single time vector.
For example here is breakdown of a set of channels from a single test:
  • 3 x 20Hz
  • 19 x 100Hz
  • 29 x 2,000Hz
  • 2 x 20,000Hx
  • 22 x nonuniform sample rate varying from ~2Hz to ~100Hz
What way would you recommend aggregating this data?
  3 个评论
Jason Nicholson
Jason Nicholson 2022-10-6
The deficiency are related to the inability to agregate channels that have a different time base.
Various operations with aggregated data should be possible. There is a lot that could be done. I am looking for what people are doing.
Walter Roberson
Walter Roberson 2022-10-6
What I do with samples with different timebases is either use timetable() retime(), or else I use resample() or interp1() . On occasion I might have reason to nufft() and then ifft()

请先登录,再进行评论。

回答(1 个)

Shubham
Shubham 2023-5-29
Hi Jason,
For aggregating this data with non-uniform sample rates, I would recommend using the tscollection object in MATLAB. The tscollection object can aggregate time-series data with a single time vector. Here's how you can create a tscollection object and aggregate your data:
  1. Create individual timeseries objects for each channel with their timestamps and values.
  2. Add each timeseries object to the tscollection object using the "addts" function. This will create a timeseries collection with each timeseries using an independent time vector.
  3. Use the "synchronize" function to create a uniform time vector across the entire tscollection.
  4. Interpolate the data from all the channels at the uniform time vector using the "resample" function.
Here's an example code snippet that shows how to do this:
% Create individual timeseries objects for each channel
ts1 = timeseries(data1, time1);
ts2 = timeseries(data2, time2);
ts3 = timeseries(data3, time3);
ts4 = timeseries(data4, time4);
ts5 = timeseries(data5, time5);
% Create a tscollection object and add each timeseries to it
tsCol = tscollection();
tsCol = addts(tsCol, ts1);
tsCol = addts(tsCol, ts2);
tsCol = addts(tsCol, ts3);
tsCol = addts(tsCol, ts4);
tsCol = addts(tsCol, ts5);
% Synchronize the timeseries in the tscollection
tsCol = synchronize(tsCol);
% Resample the data to create a uniform sample rate
uniformTime = tsCol.Time;
ts1Resampled = resample(ts1, uniformTime);
ts2Resampled = resample(ts2, uniformTime);
ts3Resampled = resample(ts3, uniformTime);
ts4Resampled = resample(ts4, uniformTime);
ts5Resampled = resample(ts5, uniformTime);
% Get the data values from each timeseries and store in a matrix
dataMatrix = [ts1Resampled.Data, ts2Resampled.Data, ts3Resampled.Data, ts4Resampled.Data, ts5Resampled.Data];
This code snippet will create a matrix with each row representing a specific time value and each column representing a channel's data. This matrix can then be used for further calculations and analysis.

类别

Help CenterFile Exchange 中查找有关 Time Series 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by