Search All of the Math Forum:

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

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

Topic: generate specific random value except some numbers
Replies: 6   Last Post: Jul 15, 2013 5:26 AM

 Search Thread: Advanced Search

 Messages: [ Previous | Next ]
 Antonio Valentine Posts: 17 Registered: 7/29/12
Re: generate specific random value except some numbers
Posted: Jul 14, 2013 4:30 AM
 Plain Text Reply

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <krtmb3\$1gq\$1@newscl01ah.mathworks.com>...
> A = [1:40];
> B = [10 13 22 27];
>
> left=[A(1) B+1];
> right=[B-1 A(end)];
> n = right-left+1;
> e = [0 cumsum(n)];
> a = floor(e(end)*rand(1,1e5));
> [~, d] = histc(a, e);
> r = a+d+A(1)-1;
>
> % Bruno

It's quite complicated but it is working perfectly.

Thanksss Bruno. :)

Date Subject Author
7/14/13 Antonio Valentine
7/14/13 Nasser Abbasi
7/14/13 Antonio Valentine
7/14/13 Bruno Luong
7/14/13 Antonio Valentine
7/14/13 Nasser Abbasi
7/15/13 Roger Stafford

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