Use retime() to resample to fractional seconds?
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
RM
el 15 de Feb. de 2018
Respondida: Peter Perkins
el 17 de Feb. de 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 comentarios
Respuesta aceptada
Steven Lord
el 15 de Feb. de 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).
Más respuestas (1)
Peter Perkins
el 17 de Feb. de 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 comentarios
Ver también
Categorías
Más información sobre Multirate Signal Processing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!