how to give delay in MATLAB?

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

How about using input(prompt) after detecting the direction. Then user has to tell robo what to do?
Fine. So explain, what "a robot" is? A hardware machine or is it a simulation? What does "detecting the direction" mean and on what does the decision about the movement depend on?
In other words: What is your question? How can we assist you?
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
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.

Categories

Products

Asked:

on 7 Nov 2016

Commented:

on 7 Nov 2016

Community Treasure Hunt

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

Start Hunting!