MathLab Question

0 comments

1.Create a new function three_d_walk(num_steps) that performs a 3-dimensional random walk of length num_steps, by starting at the origin (x, y, z) = (0, 0, 0) and rolling a fair 6- sided die to determine the direction of each step (up, down, left, right, front, back). The function should return the column vectors [x, y, z] which record the coordinates of each step of the walk.

Hint: use the two_d_walk_UDLR(num_steps) function as a template.

2. Create a new script visualize_3_d_walk that calls your function in 1. and uses the plot3() and scatter3() functions to visualize the results of a 3-dimensional walk of 10, 000 steps.
Hint: use the visualize_walks script as a template.

3. Write a script average_distance_plot that uses the distance_of_walkers() function to perform 10, 000 UDLR and angle walks of length num_steps for each value of num_steps in the list 10:10:1000, and returns the average distance from the origin in column vectors averages_UDLR and averages_angle.

Your script should also plot the resulting averages against the vector 10:10:1000 on the same axis. Use a red solid line with square markers for the UDLR averages, and a blue solid line with circle markers for the angle average. Include a legend, label your axes appropriately, and include a descriptive title.

4. Using the graph in 3., hypothesize about the functional relationship between the number of steps in a walk and the average distance of the walker from the starting point. Does the relationship seem to depend on which type of walk (UDLR or angle) is performed?

About the Author

Follow me


{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}