Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Random Walk simulation

Status
Not open for further replies.

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?
 
Replies continue below

Recommended for you

Is this homework?

TTFN
faq731-376
7ofakss
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor