How to make the time invtervals between two index fixed when plotting in real time using function 'tic toc'
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi everyone,
I meet a problem when I'm trying to plotting some signals in real time from Arduino to Matltb. I use 'tic toc' to get elapsed time and it works. But when I look back to the 'time' output, the intervals between two neighouring index are irregular. But I want the time intervals to be fixed, for example, it recordes index every 0.3 seconds regularly. My code is look like below:
a = arduino()
%some other code here
tic
while ishandle(plotGraph1)
count = count + 1;
time(count) = toc;
%some other code here
end
I understand why that tic toc can lead to such irregular time intervals, so is there any other options I can use to represent the elapsed time with consistent increasement? Thanks a lot for your help!
댓글 수: 0
답변 (1개)
KALYAN ACHARJYA
2021년 3월 15일
편집: KALYAN ACHARJYA
2021년 3월 15일
"But I want the time intervals to be fixed, for example, it recordes index every 0.3 seconds regularly. My code is look like below"
This way?
while condition
%record
pause(0.3)%
end
Tic start is a stopwatch timer, it return time requiremnets for the code execution until toc. Exact Time: Please note, even in the given code, you must calibrate the fraction of tiny fraction of second required to run the loop (excluding pause).
참고 항목
카테고리
Help Center 및 File Exchange에서 Graphics Performance에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!