Create random plotted point

1 view (last 30 days)
am
am on 31 Jul 2014
Commented: Image Analyst on 3 Aug 2014
Hi there, Basically I need to create a script that takes a random plotted point within the parameters of -100 and 100 and I need to move it 1 space over in any random direction. I need this to occur 100 times so basically the randomly plotted point moves 1 space over, in any direction, 100 times. (using a vector?) How could I go about doing this? Im new to matlab so sorry if this sounds a little basic and vague Thanks for all the help!
  1 Comment
Geoff Hayes
Geoff Hayes on 31 Jul 2014
Does the 1 space over in any random direction correspond to a finite number of directions i.e. {north,south,east,west}, or {north,south,east,west,northwest,etc.}? Is the object moving within a checkerboard type of background?
Does the random plotted point within the parameters of -100 and 100 mean any integer within this range? If so, you could use randi to get that integer.

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 31 Jul 2014
Did you look up rand in the help and see how you can set it up to get ay random number between a and b, which in your case would be -100 and +100 and -1 and +1?
See my random walk demo, attached.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!