Set time reference for incoming samples
3 views (last 30 days)
Show older comments
Hi all,
I have a system consisting in multiple Bluetooth devices that send samples to Matlab at a specific rate. Since I'm using wireless communications, not every sample from every device will arrive to Matlab at the exact same time. So my aim is to use a Matlab clock reference to "align" the samples sent from every Bluetooth device so I can plot them using the same time axis.
At the end I must be able to store the samples this way (table shows the arrival time of 3 samples from each device)
| Matlab time reference | BT device 1 | BT device 2 | BT device 3 |
| 1 ms | 1.1 ms | 1.12 ms | 1.09 ms |
| 2 ms | 2.01 ms | 2.09 ms | 2.1 ms |
| 3 ms | 3.03 ms | 3.11 ms | 3.1 ms |
I thought about using Matlab "clock" function, which provides date and time with 4 decimal digits of precission, but I'd like to know if there's a more appropriate method.
Thanks in advance,
Edu
2 Comments
Answers (1)
Jan
on 4 Aug 2017
Under Windows and Linux see: https://www.mathworks.com/matlabcentral/fileexchange/16534-high-accuracy-timer for a high accuracy timer. I'm not sure if it works under Mac also.
3 Comments
Jan
on 4 Aug 2017
Edited: Jan
on 4 Aug 2017
Your data
| 2 ms | 2.01 ms | 2.09 ms | 2.1 ms |
looks like you need a resolution with at least 0.01 miliseconds.
It is very easy to compile the C file and use it like any other Matlab function. In addition clock replies the time with miliseconds precision already. Therefore I'm not sure what your statement "provides date and time with 4 decimal digits of precission" means. See:
c = clock;
c(6)
The question is, how meaningful these miliseconds are, because neither Matlab nor Windows is a real time systems and the execution of this command can take more than a few miliseconds already - if the OS starts a hard disk defragmentation or the memory is exhausted this can be seconds also.
See Also
Categories
Find more on Coexistence Modeling in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!