How to use a timer most efficently for finding pings/second

조회 수: 3 (최근 30일)
Aaron Atkinson
Aaron Atkinson 2019년 12월 7일
답변: Star Strider 2019년 12월 7일
Im writing a code that uses a pressure sensor. The code automatically transfers the pressure sensor input too force and once then force exceeds a certain amount it is to take a "ping". I've thought about using a timer to do this by having the timer run and whenever there is a ping the timer restarts and the time between the pign before last and the most recent ping is saved to an array before being averaged to find the pings/sec. My problem is that I dont know how to use timers, how should I go about using them in this way and is this way the best way to go about doing so?

채택된 답변

Star Strider
Star Strider 2019년 12월 7일
One option for recording the times would be to use the clock function. Then use the etime function to recover the elapsed times in seconds and fractions of seconds afterwards.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Clocks and Timers에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by