how to give delay in MATLAB?

3 views (last 30 days)
VAIBHAV GUPTA
VAIBHAV GUPTA on 7 Nov 2016
Commented: Walter Roberson on 7 Nov 2016
I want my robot to first detect the direction and the wait to take decision that whether to go forward or stay stationary.
  4 Comments
VAIBHAV GUPTA
VAIBHAV GUPTA on 7 Nov 2016
I am using MATLAB to detect red object using image processing. So, basically what it has to do it detect the red object, so if it is slightly on the right it will first turn the robot right and then after give a pause to see how whether it is in line or not. Then move towards if the distnace b/w bot and object is more than the set reference.
for object = 1:length(stats)
if(object==1) %detect only one major red object
bb = stats(object).BoundingBox;
bc = stats(object).Centroid;
ar=stats(object).Area;
k=29000; %decide this experimentally, i have already explaine the procedure
dist=k/ar;
%if(dist>5) %Change 5 to an experimentally deduced value
% fprintf(s,'F');
% else if(bc(1)<80) %Change 80 to an experimentally deduced value (80 is 1/4 of 320 (screen size))
% fprintf(s,'L');
% else if(bc(1)>240) %Change 240 to an experimentally deduced value (240 is 3/4 of 320 (screen size))
% fprintf(s,'R');
% else
% fprintf(s,'S');
% end
Walter Roberson
Walter Roberson on 7 Nov 2016
So why is pause() not the solution you are looking for? It delays. Is there more that a delay has to do than to delay?

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 7 Nov 2016
See pause()

Products

Community Treasure Hunt

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

Start Hunting!