Use retime() to resample to fractional seconds?
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
RM
le 15 Fév 2018
Réponse apportée : Peter Perkins
le 17 Fév 2018
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.
0 commentaires
Réponse acceptée
Steven Lord
le 15 Fév 2018
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).
Plus de réponses (1)
Peter Perkins
le 17 Fév 2018
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.
0 commentaires
Voir également
Catégories
En savoir plus sur Multirate Signal Processing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!