Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: How to make a loop for this problem!

  • To: mathgroup at
  • Subject: [mg75376] Re: How to make a loop for this problem!
  • From: Albert <awnl at>
  • Date: Fri, 27 Apr 2007 05:24:29 -0400 (EDT)
  • References: <f0pkt5$28h$>

pskmaths at wrote:
> Hi all,
> This comand:
> A = Array[Random[Integer] &, {3, 3}]
> generates a 3x3 random matrix its terms between 0 and 1.

if you use Random[Integer] then the entries will be either 0 or 1, not 
anything in between. There are only 512 possibilities (9^3) of 3x3 
Matrices containing 0 or 1 only. So it does not make much sense to 
generate them this way...

> I need to make a loop that geerates a finite number of matrices, let's
> say 512 and this loop check that non of the matrices is equal to
> another one (no repeated matrices)
> I can geerate thoses random, matrices with this command:
> Do[Print[Array[Random[Integer] &, {3, 3}]], {512}]
> but I may have two matrices that are equal and also as far as I know I
> cann't use the out put because of the command, Print.

to generate 512 unique matrices with entries between 0 and 1 you could use:

matrixlist = Take[

you can then access the 12th matrix with:


The code above generates some extra matrices, then uses Union to delete 
doubles and takes the first 512 unique matrices. Of course it could 
happen that the 600-512 extra matrices are not enough, but I think that 
is very very unlikely and easy to solve (in fact I think it almost never 
happens that you will get a double at all!). Also note that the matrices 
are sorted in some way when using Union. If that is a problem you can 
use UnsortedUnion which is defined in the further examples section for 
the documentation of Union...



  • Prev by Date: Re: How to make a loop for this problem!
  • Next by Date: Re: Porting waveforms out of Mathematica and into a D/A converter
  • Previous by thread: Re: How to make a loop for this problem!
  • Next by thread: Re: How to make a loop for this problem!