Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Matlab Help

  1. Nov 12, 2007 #1
    Okay... I am using the randn function for a sequence of normally distributed numbers.
    I am writing a program whereby I need to use this randn to give me random x and y values whose position r is less than 1

    i.e. that is to say that all points fall within a 2 x 2 square centred at (0, 0).
    And I MUST use randn

    Can anyone help me achieve this.

  2. jcsd
  3. Nov 12, 2007 #2
    Do you need the points to have any particular distribution (normal, uniform, etc.)? You could just discard any generated points that fall outside the 2 x 2 square, but then the points will not have a normal distribution.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook