Timeseries, Timetable, timeseriescollection, Time Data Aggregation

조회 수: 13 (최근 30일)
Jason Nicholson
Jason Nicholson 2022년 10월 4일
답변: Shubham 2023년 5월 29일
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