The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Random 3-D Walk
Replies: 1   Last Post: Oct 21, 2012 10:34 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]

Posts: 13,022
Registered: 12/26/06
Re: Random 3-D Walk
Posted: Oct 21, 2012 10:34 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Have a for loop over the number of steps you want to take, say a thousand or so but start with around 10 or 20 while you're still developing and debugging it. Then inside the loop get random numbers with rand() and add it to the x and y coordinate values. Then use an if statement to see if adding that random number would put the particle on the other side of the barrier. If it would, change the coordinate to what it would be as if it had bounced off that barrier.

Date Subject Author
Read Random 3-D Walk
Read Re: Random 3-D Walk

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.