Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Sudoku Matrix
Date: Mon, 5 Mar 2012 05:15:13 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 9
Message-ID: <jj1i51$ke1$1@newscl01ah.mathworks.com>
References: <jj1335$8e8$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 1330924513 20929 172.30.248.35 (5 Mar 2012 05:15:13 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 5 Mar 2012 05:15:13 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:759858

"Ryan" wrote in message <jj1335$8e8$1@newscl01ah.mathworks.com>...
> I am trying to generate a random matrix using only numbers 1-9 once each. I have figured out how to make one with the same total sum as the Sudoku matrix however it doesn't guarantee the conditions of a proper Sudoku matrix. Does any one have any ideas on how to create this random Sudoku matrix?
- - - - - - - - -
 I = [randperm(3),randperm(3)+3,randperm(3)+6];
 J = [3*randperm(3)-2,3*randperm(3)-1,3*randperm(3)];
 S = zeros(9);
 S(I+9*(J-1)) = randperm(9);

Roger Stafford