Uses the high-resolution performance counter to get the time which exceeds one microsecond accuracy.
time = hat;
% do some calculations
diff = hat - time;
Ivo Houtzager (2021). High Accuracy Timer (https://www.mathworks.com/matlabcentral/fileexchange/16534-high-accuracy-timer), MATLAB Central File Exchange. Retrieved .
Inspired: Simulink Block for Real Time Execution
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Create scripts with code, output, and formatted text in a single executable document.
Nice function.
It gives the "Output argument "time" (and maybe others) not assigned during call to "hat"." error on my end. What do I need to do in order to make it work?
How can I use this mex file to make in interrupt timer please ? something similar to timer() class
I'm trying to read my sensor measurement at a constant rate of 2000 sps with high microsecond accuracy as much as possible
the timer() class has an error of about 10 milliseconds, this is so huge comparing to 2000 sps
Thanks
The m file has no body!!
the function is not working cuz there is no assignment for time as there is no body.
Thank you very much.
Your code was very helpful in the creation of my own high-accuracy real-time S-Function rate limiter.
Cheers!
I'm working on video recording, but with pause(n) I can hardly get right frame rate. This really helps me out!
hey, this timer really helped me out, so, since inline syntax is kind of being done away with, could you provide another syntax for compiling the C file? tnx!
I think the counter has to be calibrated, although the difference is usually very small.
I need help getting this code to work. I have Visual Basic 2008 Express Edition installed on my PC but I'm not sure how I initiate all of this with matlab.
Thanks for any help.
It appears that the timer call has significant overhead itself, so realize that by using it you may add to your execution time and skew some measurements.
nice C program. Solved Matlab unaccurate timing problems.