Modify the MatLab code below to answer the following prompt. Adjust pw by gradually…
- User
Modify the MatLab code below to answer the following prompt.
Adjust pw by gradually increasing it from 0 to near 1. As you do this, repeat number 7 in the previous problem for different values of pw. Determine the appropriate way to translate number of steps to time by modifying the relationship: t = n*𝜏 (the new formula will be a function of pw ). Now, consider two kinds of media. Media A fills the pipe for x ≥ 0, while media B fills the pipe for x < 0. Suppose the diffusion constant for media A is 10^-7 cm^2 / sec and the diffusion constant for media B is 10^-8 cm^2 / sec. By using different pw for media A and B, answer the following questions.
- Visualize the random walk trajectories
- In the x-direction, calculate the mean squared displacement as a function of number of steps.
- In the y-direction, calculate the mean squared displacement as a function of number of steps.
- For 1,000,000 walks, plot the histogram of locations of the random walker in the x-direction after 100, 1000, 10000, 100000, 1000000 steps.
- For 1,000,000 walks, plot the histogram of locations of the random walker in the y-direction after 100, 1000, 10000, 100000, 1000000 steps.
- Assistant
There is no MatLab code provided in the question. Please provide the code so that I can modify it to answer the given prompt.