Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I don\'t need a complete solve. I need help on how to incorperate the \"Time to

ID: 3843214 • Letter: I

Question

I don't need a complete solve. I need help on how to incorperate the "Time to complete" portion of the table into my script. As you can see, my script works as though ever action is on a 1 minute interval, which isn't the case. Fast plod takes 2 minutes @ 0.0333mpm and slow plod takes 4 minutes @ 0.0083mpm. I want to do something along the lines of, in the case of fast plod, a vector <previous_distance+0.0333,previous_distance+0.0333> to reflect the distance and time, and adding that to my current distance in my while loop...or something like that

Here's what I have for the tortoise part:

clc
clear
%% Conversion mph to mpm
% Tortoise stuff (mpm)
FP=2/60;
SP=0.5/60;
S=-1/60;
%% Tortoise

distance=0;
ind=1;
t(ind)=1;

while distance<4.2
for action_type=randi([0 100])
if action_type<=20 % if 20% fast plod
ind=ind+1;
fprintf('fast plod')
t(ind)=t(ind-1)+1;
distance=FP*t
elseif action_type>=20 && action_type<=80 % if 60% slow plod
ind=ind+1;
fprintf('slow plod')
t(ind)=t(ind-1)+1;
distance=SP*t;
elseif action_type<=100 && action_type>=80 % if 20% slip
ind=ind+1;
fprintf('slip')
t(ind)=t(ind-1)+1;
distance=S*t;
end
end
end

You are to write a program that recreates one of the truly great moments in history: the classic race of the tortoise and the hare. You will use random number generation to develop multiple simulations of this event, and estimate how likely each isto win a given race. The racetrack is 4.2 miles long. The first contender to travel that distance wins. The course weaves its way up the side of a slippery mountain, so occasionally the contenders lose ground. The competitors can move in a variety of actions, which move them forward or backward at a certain velocity. After doing one action for a specific time, they immediately do another one. Each action has a certain frequency of occurrence (assumed to be independent of previous actions. The action type, velocity, time to complete, and frequency for each competitor is shown in the following table. Animal Action Type Frequency Time to complete Velocity 20Ro Tortoise Fast Plod 2 minutes Forward at 2 mph Forward at 2 mph Slow plod. 60% 4 minutes Slip minute Backward at 1 mph Hare Sleep 20Ro 45 minutes No movement 10% 1 mimute Forward at 10 mph Small hops 40% 5 minutes Forward at 3 mph Big Slip Backward at 8 mph 10% 1 mimute Backward at 3 mph Small slip 1 mimute

Explanation / Answer

first of all you are not incrementing distance .

make it like this distance=distance + Fp*t

secondly make a vector t=[2,4,1];

and a scalar variable timetocomplete=0;

the make following changes

---------------------------------------------------------------------

clc
clear
%% Conversion mph to mpm
% Tortoise stuff (mpm)
FP=2/60;
SP=0.5/60;
S=-1/60;
%% Tortoise

distance=0;
t=[2,4,1];

timetocomplete=0;

while distance<4.2
for action_type=randi([0 100])
if action_type<=20 % if 20% fast plod
  
fprintf('fast plod')
timetocomplete=timetocomplete+t(1);
distance=distance+FP*t(1)
elseif action_type>=20 && action_type<=80 % if 60% slow plod
  
fprintf('slow plod')
  timetocomplete=timetocomplete+t(2);

distance=distance+SP*t(2);
elseif action_type<=100 && action_type>=80 % if 20% slip
  
fprintf('slip')
    timetocomplete=timetocomplete+t(3);

distance=S*t(3);
end
end
end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote