MathGroup Archive 2005

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

Search the Archive

Re: Matrix question


On 10 Sep 2005, at 11:46, sandog wrote:

> i want to create a NxN matrix with zeros but i want a percentage of  
> the matrix spots to be one at random spots any idea? cause i have  
> no clue how to do that.
> Any help appreciated thx .

Table[If[Random[] < r, 1, 0], {n}, {n}]

Replace r with the desired frequency of ones and n with the dimension  
of the matrix you want.


  • Prev by Date: Re: Matrix question
  • Next by Date: Re: Matrix question
  • Previous by thread: Matrix question
  • Next by thread: Re: Matrix question