Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Randomly permute a given set of numbers
Date: Sun, 12 Sep 2010 06:00:05 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 9
Message-ID: <i6hq95$fjn$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1284271205 15991 172.30.248.38 (12 Sep 2010 06:00:05 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 12 Sep 2010 06:00:05 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2493299
Xref: news.mathworks.com comp.soft-sys.matlab:669355

I have a question wherein I am required to generate integers between 2 and m randomly, without repetition (in an n x m matrix). Therefore, total number of integers generated in a row must be m, with at least two non-zero values. Any way to do this?

The matrix should look somewhat like this (randomly generated):

     0     0     4     1     2     3
     3     1     2     0     0     0
     0     2     3     0     4     1
     0     0     1     0     0     2
     3     0     0     1     0     2