How can I write codes for two activities running simultaneously and related by time?
1 view (last 30 days)
Show older comments
Shamsuddeen Abdullahi on 31 Oct 2019
I want to implement the following scenario as described below.
In a basket ball court, they are 10 people. Each person is given say 20 seconds to throw his ball into a basket, one after the other. i.e 1st person uses 20 seconds to throw his ball. After he finishes (after 20 seconds), the next (2nd) person will throws his ball. The process continues until the 10th person and the whole process is repeated again.
Now, Each of the above persons have some extra balls with his number printed on it and given to a messenger stationed at some distance away from him. When 1st person throws his ball, the messenger will travel at a constant speed (v) towards him and give him an extra ball. The messenger knew the time he took from his intial position and will be able to know the person that is currently throwing his ball after he had arrived at the position of the 1st person. So he will move straight to that person and issue him a new ball.
Example: assuming the messenger arrived at the position of the 1st person after 65 seconds. After giving an extra ball to the 1st person his ball, the messenger will know that it is the 4rd person (65/20 >3) that is currently throwing his ball and will then moved straight to give the 4th person a new ball. i.e the next person to be issued a ball depends on the time of arrival of the messenger at the location of the previous person.
I started writing some codes but got confused. Can someone help with an idea of how to go about it or some codes?
% let v be her velocity
n=10; % number of persons
% o is the initial position of the woman
% b status of a person b=1 : person has a ball; b=0 : person has no ball
% p next person currently throwing
c= distance (o to 1)/v
% next person to attend to
i= ceil (time/20);
Find more on Descriptive Statistics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!