Results 1 to 2 of 2

Math Help - matlab

  1. #1
    Newbie
    Joined
    Mar 2009
    From
    atlanta
    Posts
    1

    matlab

    how can I generate a discrete random number from 3 possible numbers in matlab. Ex I want to choose ( 0 or 1 or -1)
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Moo
    Moo is offline
    A Cute Angle Moo's Avatar
    Joined
    Mar 2008
    From
    P(I'm here)=1/3, P(I'm there)=t+1/3
    Posts
    5,618
    Thanks
    6
    Hello,
    Quote Originally Posted by florezl View Post
    how can I generate a discrete random number from 3 possible numbers in matlab. Ex I want to choose ( 0 or 1 or -1)
    Well, you could define u=rand() and then, [if u<1 [if u<2/3 [if u<1/3, x=-1] x=0] x=1].
    (rand() gives a value between 0 and 1)
    Last edited by Moo; March 18th 2009 at 03:52 PM. Reason: changed a bit the text
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Matlab help
    Posted in the Math Software Forum
    Replies: 1
    Last Post: February 11th 2010, 03:59 AM
  2. Matlab FFT Help
    Posted in the Math Software Forum
    Replies: 0
    Last Post: June 3rd 2009, 01:48 PM
  3. help about ODE in matlab
    Posted in the Math Software Forum
    Replies: 1
    Last Post: May 31st 2009, 04:10 AM
  4. Matlab Please help me
    Posted in the Math Software Forum
    Replies: 8
    Last Post: November 10th 2008, 05:40 PM
  5. Matlab
    Posted in the Calculus Forum
    Replies: 3
    Last Post: August 20th 2008, 11:39 PM

Search Tags


/mathhelpforum @mathhelpforum