Path: news.mathworks.com!not-for-mail
From: "Luigi Giaccari" <giaccariluigi@msn.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Randomization_same number
Date: Fri, 6 Nov 2009 21:58:02 +0000 (UTC)
Organization: L'aquila
Lines: 14
Message-ID: <hd265a$e8e$1@fred.mathworks.com>
References: <hd249a$im2$1@fred.mathworks.com>
Reply-To: "Luigi Giaccari" <giaccariluigi@msn.com>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1257544682 14606 172.30.248.37 (6 Nov 2009 21:58:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 6 Nov 2009 21:58:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1548775
Xref: news.mathworks.com comp.soft-sys.matlab:583133


"Kostas " <eclipse_dsotm@hotmail.com> wrote in message <hd249a$im2$1@fred.mathworks.com>...
> Hi all,
> 
> I am trying to present 4 different numbers 120 times in a vector, in a randomized order. But the thing is that I try to avoid repeating the same number twice in a row, and in the same time to keep the repetition frequency of each number the same (= 30). 
> 
> Do you have any ideas? 
> 
> Thanks

BUild the 120 element vector in a sorted order than use "randperm"

The "randperm" will help you, but you need to postprocess the data to change duplicate values on a single row. A swap should be good.

http://www.advancedmcode.org/