Use retime() to resample to fractional seconds?

4 ビュー (過去 30 日間)
RM
RM 2018 年 2 月 15 日
回答済み: Peter Perkins 2018 年 2 月 17 日
Timetables look to be very flexible, but I have data timed to msecs and would like to resample to some higher fractional second rate, such as 0.1 sec. Is there any way to use retime to do that? It appears retime may be limited to 1 second in resolution.

採用された回答

Steven Lord
Steven Lord 2018 年 2 月 15 日
The smallest value allowed for the newTimeStep input argument describe in the documentation for retime is 'secondly', but you can create a vector of new times with whatever spacing you want and use that as the newTimes input argument for retime.
% Get a starting time
N = datetime('now');
N.Format = 'HH:mm:ss.SSSS';
% Make the timetable spanning 1 second with some arbitrary data to retime
tt = timetable(N+seconds([0; 1; 3; 6; 10]./10), [0; 1; 10; 100; 1000])
% New time vector with spacing (timing?) of 0.1 second
tv = (N:seconds(0.1):N+seconds(1)).'
% retime it
newtt = retime(tt, tv, 'linear')
The value of Var1 for the third entry in tv, N+seconds(0.2), should be 5.5 which is halfway between the value of 1 for N+seconds(0.1) and the value of 10 for N+seconds(0.3).
  1 件のコメント
RM
RM 2018 年 2 月 15 日
That is exactly what I needed. Thank you.

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

その他の回答 (1 件)

Peter Perkins
Peter Perkins 2018 年 2 月 17 日
If you are working in sub-second resolutions, probably best to use the milliseconds function, rather than seconds, for anything involving fractional seconds. By the time you type 0.1, you're into floating point round-off. That may or may not matter; in many cases it won't. And of course this really only pushes the issue down into sub-MILLIsecond resolutions.

カテゴリ

Help Center および File ExchangeMultirate Signal Processing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by