
Re: generate specific random value except some numbers
Posted:
Jul 15, 2013 5:26 AM


"Antonio Valentine" <chanloha@gmail.com> wrote in message <krtkqb$rsc$1@newscl01ah.mathworks.com>... > Your suggestion is quite straightforward. May I ask for an option of > > A = [1:40]; > B = [10 13 22 27]; > > Then I can separate into two vectors where vector B the numbers I want to skip it. > > Is that possible?              A = 1:40; B = [10 13 22 27];
S = setdiff(A,B); r = S(randi(numel(S),n,1));
where n is the desired number of random values.
Note: This should work for any sets A and B, integervalued or otherwise, provided their 'setdiff' is not empty.
Roger Stafford

