Dgrayman
Bioengineer
- Feb 12, 2012
- 1
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
ranwalk2d.m
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.
n=100000;
colorstr=['b' 'r' 'g' 'y'];
for k=1:4
z=2.*(rand(2,n)<0.5)-1;
x=[zeros(1,2); cumsum(z')];
col=colorstr(k);
plot(x,1),x,2),col);
hold on
end
grid
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. In any case how would i start from the beginning doing a random walk simulation?
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
ranwalk2d.m
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.
n=100000;
colorstr=['b' 'r' 'g' 'y'];
for k=1:4
z=2.*(rand(2,n)<0.5)-1;
x=[zeros(1,2); cumsum(z')];
col=colorstr(k);
plot(x,1),x,2),col);
hold on
end
grid
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. In any case how would i start from the beginning doing a random walk simulation?