Question: Please do number 8 in MATLAB code. Thankyou! indow Help a HW Chapter 6_Animation.pdf (page 4 of 6) Q Search 8. A random walk in

Please do number 8 in MATLAB code. Thankyou!

Please do number 8 in MATLAB code. Thankyou! indow Help a HW

indow Help a HW Chapter 6_Animation.pdf (page 4 of 6) Q Search 8. A random walk in two dimensions. Write a program, rw2d.m, to describe a walker making a random walk with unit steps in the x-y plane. The walker starts at the origin. Represent the walkers N positions using MATLAB arrays x and y. A good value to start with would be 1 x 10. The walk starts with x(1)-0, y(1) -0 (initialize both arrays to zero). Use a for loop to calculate the walker's moves. At each step the walker uses a random number to decide whether to take a step. . North (y increases by 1; x stays the same). . South (y decreases by 1; x stays the same). . East (x increases by l; y stays the same). . West (x decreases by 1; y stays the same). The walker always takes a step of lenth 1 Notes: a. Note that one can generate a random number in the set(l.2,3,4] by using the command idirection-randi(4);. b. Animate the plot by plotting at each step istep. i. The starting position at the origin as an asterisk. ii. The path the walker has taken up to now by a curve. ii. The position of the walker at the present as an "o." E.g., plot(0, 0, 'r*', axis equa draw now Lists None indow Help a HW Chapter 6_Animation.pdf (page 4 of 6) Q Search 8. A random walk in two dimensions. Write a program, rw2d.m, to describe a walker making a random walk with unit steps in the x-y plane. The walker starts at the origin. Represent the walkers N positions using MATLAB arrays x and y. A good value to start with would be 1 x 10. The walk starts with x(1)-0, y(1) -0 (initialize both arrays to zero). Use a for loop to calculate the walker's moves. At each step the walker uses a random number to decide whether to take a step. . North (y increases by 1; x stays the same). . South (y decreases by 1; x stays the same). . East (x increases by l; y stays the same). . West (x decreases by 1; y stays the same). The walker always takes a step of lenth 1 Notes: a. Note that one can generate a random number in the set(l.2,3,4] by using the command idirection-randi(4);. b. Animate the plot by plotting at each step istep. i. The starting position at the origin as an asterisk. ii. The path the walker has taken up to now by a curve. ii. The position of the walker at the present as an "o." E.g., plot(0, 0, 'r*', axis equa draw now Lists None

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!