Question: Using matlab script so far: clc clear run_count=0 while run_count %% Tortoise ind = 1; distance_tort(ind) = 0; ind_tort_t(ind) = 0; t_tort = 0; ind
Using matlab
script so far:
clc clear run_count=0 while run_count
%% Tortoise
ind = 1; distance_tort(ind) = 0; ind_tort_t(ind) = 0; t_tort = 0; ind = 2;
while distance_tort(ind-1)20 && action_type_tort80 % if 20% slip ind_tort_t(ind)=ind_tort_t(ind-1)+1; t_tort = t_tort + 1; distance_tort(ind) = distance_tort(ind-1) + (S*1); ind = ind + 1; end end end
%% Rabbit
ind = 1; distance_rab(ind) = 0; ind_rab_t(ind) = 0; t_rab = 0; ind = 2;
while distance_rab(ind-1)20 && action_type_rab30 && action_type_rab70 && action_type_rab80 % if 20% small slip ind_rab_t(ind)=ind_rab_t(ind-1)+1; t_rab = t_rab + 1; distance_rab(ind) = distance_rab(ind-1) + (SS*1); ind = ind + 1; end end end
win_tort=0; win_rab=0;
if ind_tort_t(end)>ind_rab_t(end) fprintf('Tortoise has won!') win_tort=win_tort; elseif win_rab=ind_tort_t(end) 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 any 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 Slow plod 60% 4 minutes Forward at mph Slip minute Backward at 1 mph Seep 20Ro Hare 45 minutes No movement Big hops 10% Forward at 10 mph Small hops 40% 5 minutes Forward at 3 mph Big Slip 10% minute Backward at 8 mph Backward at 3 mph Small slip Model a series of races using MATLAB and do the following: 1. Perform 100 trials of the race. 2. Record the number of races won by each animal. Present this result in your report. 3. Record how long it takes for each competitor to complete each race. Create a histogram for each. 4. Keep track of the race progress (time and position) for each animal's fastest and slowest run. Make a plot of position vs. time that features four lines: one for each competitor's fastest and slowest runs