Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Random walk code

DgraymanDgrayman Member Posts: 4
Hello, this is the Question:
Suppose you want to know how often a single source of fungus will spread more than one foot from a fallen tree. You will be using a computer simulation to answer the question.

i found this code using the m file ranwalk2d.m:

2-dimensional random walk

Plots the points (u(k),v(k)), k=1:n, in the (u,v)-plane, where (u(k)) and (v(k)) are one-dimensional random walks. The sample code plots four trajectories of the same walk, four different colors.

colorstr=['b' 'r' 'g' 'y'];
for k=1:4
z=2.*(rand(2,n)<0.5)-1; <br /> x=[zeros(1,2); cumsum(z')];
hold on

The problem is i don't want the graph to go below 0 on the y axis. In other words pertaining to the problem, the fungus cant go back to its starting point.

I'm not a computer science person so i'm not that knowledgeable. Can Someone please guide me on how to do random walks on matlab?


Sign In or Register to comment.