Smooth Data with duplicate timestamps

11 ビュー (過去 30 日間)
Jonathan
Jonathan 2025 年 3 月 25 日
編集済み: dpb 2025 年 3 月 25 日
I have a timetable of data of which I am trying to take a moving average using smoothdata function. There is at least one duplicate timestamp in my timetable, and this results in an error in smoothdata.
I tried using only odd indices, which alows the smoothing function to work but filters out half of my data.
Smooth_table = smoothdata(time_table.Variables, "movmean", seconds(0.2), "SamplePoints", time_table.Time);

回答 (1 件)

dpb
dpb 2025 年 3 月 25 日
Smooth_table=smoothdata(time_table.Variables, "movmean", seconds(0.2));
Just don't try to specify the output sampled time and you'll get the moving average of all.
Or, use @doc:retime and aggregate/select from the duplicates by some method to eliminate only them if you must have some specific output time vector.
  2 件のコメント
Jonathan
Jonathan 2025 年 3 月 25 日
Thanks for the suggestion, it still produces the error: 'Row times' value contains duplicates.
Your retime suggestion could work, but would interfere with a time-alighnent that needs to be performed as well, after this smoothing operation.
dpb
dpb 2025 年 3 月 25 日
編集済み: dpb 2025 年 3 月 25 日
Well, then, you'll have to either accept the limitation of non-unique tmestamps if determined to use smoothdata or switch over to using movmean which will accept repeated time data because it doesn't actually use the time or write your own function if not willing to aggregate the existing time data. The one other alternative could be to "jigger" the timestamp of the duplicated time by just enough to make them non-unique; I don't know how tight your timing requirements are.
If you would attach a representative data file (.mat ok), somebody here might take another crack at it...

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeData Preprocessing についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by