Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: generate specific random value except some numbers
Date: Mon, 15 Jul 2013 09:26:10 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 21
Message-ID: <ks0f7i$4ct$1@newscl01ah.mathworks.com>
References: <krtg0j$ia0$1@newscl01ah.mathworks.com> <krtkdb$oj$1@speranza.aioe.org> <krtkqb$rsc$1@newscl01ah.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-01-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1373880370 4509 172.30.248.46 (15 Jul 2013 09:26:10 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 15 Jul 2013 09:26:10 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:799316

"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, integer-valued or otherwise, provided their 'setdiff' is not empty.

Roger Stafford