Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Generating sequence of 0s and 1s with no repetition
Date: Mon, 22 Jul 2013 17:32:10 +0000 (UTC)
Organization: Champalimaud Foundation
Lines: 8
Message-ID: <ksjqaq$omm$1@newscl01ah.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-04-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1374514330 25302 172.30.248.35 (22 Jul 2013 17:32:10 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 22 Jul 2013 17:32:10 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 3127955
Xref: news.mathworks.com comp.soft-sys.matlab:799736

Hello.
I need to generate a sequence of 100 numbers composed of 0s and 1s only.
But I must guarantee that no more that 3 repetitions occur.
For xample:
1 2 2 1 2 2 1 1 1 2 1... its ok
1 2 1 2 2 2 2 1  it's not.
I used randi for the generation of the sequence. But i'm a bit stuuck with the remaining part. I'm sure there is an efficient way of achieving this.
Thanks for any help.