How to calculate time elapsed during some continous code?
조회 수: 1 (최근 30일)
이전 댓글 표시
I am applying some odometry discrete equations and i want to calculate time difference between the two steps. I am trying to use etime but it does not work. Here is part of my code
rob=setParam(); % Robot Parameters previousTime=clock;
%% Running Loop while(true)
if count==1
% for Inital conditions
posX(count)=0;
posY(count)=0;
heading(count)=0;
end
rpmLeftWheel=readSpeed(encoderLeft);
rpmRightWheel=readSpeed(encoderRight);
currentTime=clock;
dt=etime(currentTime,previousTime);
[posX,posY,heading]= computeOdometry(rpmLeftWheel,rpmRightWheel,dt,count,rob);
previousTime=currentTime;
count=count+1
댓글 수: 0
채택된 답변
Abhay SAMUDRASOK
2018년 7월 4일
편집: Abhay SAMUDRASOK
2018년 7월 4일
Try tic toc in your code. It would do the job
tic
if count == 1
% for Inital conditions
posX (count) = 0;
posY (count) = 0;
heading (count) = 0;
end
rpmLeftWheel = readSpeed (encoderLeft);
rpmRightWheel = readSpeed (encoderRight);
toc
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Arduino Hardware에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!