From: Walter Roberson on
Frank Sabouri wrote:

> Let me ask my question in other way: I have a matrix of data (140X15), I
> want to randomly generate as much as possible sub-matrices (6X15). It
> was why I used "nchoosek" to randomly set the sub-matices. There is any
> function that allow me to creat these submatices.

That would be 9381724380 combinations, each of which would occupy
6 * 15 * 8 = 720 bytes (unless you can use a datatype smaller than double
precision). The total would be 6291 gigabytes.

However, if you want "as many as possible", then you don't want to -randomly-
select subsets, you want to do all of them in sequence, since you are going to
eventually cover all of them. If your program is such that you can process one
of the submatrices and then throw that submatrix away, then you can use an
algorithm that iterative gives you the "next" submatrix each time, and you
would only need the 720 bytes plus the bytes you need to hold your
intermediate results plus some overhead bytes to store the state of the
iterator. I calculate that that would bring the calculation into the realm of
feasibility -- though it might take a few hours, depending on how much
manipulation of the matrix you need to do.
From: Roger Stafford on
"Frank Sabouri" <Frank.Sabouri(a)gmail.com> wrote in message <hn6pst$d24$1(a)fred.mathworks.com>...
> Hello -
>
> Let me ask my question in other way: I have a matrix of data (140X15), I want to randomly generate as much as possible sub-matrices (6X15). It was why I used "nchoosek" to randomly set the sub-matices. There is any function that allow me to creat these submatices.
>
> Frank

If what you mean is that you want to randomly select a single set of 6 rows out of 140 rows of a matrix as a submatrix, then what you need is 'randperm', not 'nchoosek'. The latter would give you all possible such choices, which is an awful lot of choices, namely 9,381,724,380 of them.

For a single submatrix:

p = randperm(140);
submatrix = matrix(p(1:6),:);

(If you need many such submatrices, repeat the above. If you are worried about the very remote chance of repetitions, test for and reject them.)

Roger Stafford
From: Frank Sabouri on
Thanks Roger...Frank
"Roger Stafford" <ellieandrogerxyzzy(a)mindspring.com.invalid> wrote in message <hn6sq5$g3s$1(a)fred.mathworks.com>...
> "Frank Sabouri" <Frank.Sabouri(a)gmail.com> wrote in message <hn6pst$d24$1(a)fred.mathworks.com>...
> > Hello -
> >
> > Let me ask my question in other way: I have a matrix of data (140X15), I want to randomly generate as much as possible sub-matrices (6X15). It was why I used "nchoosek" to randomly set the sub-matices. There is any function that allow me to creat these submatices.
> >
> > Frank
>
> If what you mean is that you want to randomly select a single set of 6 rows out of 140 rows of a matrix as a submatrix, then what you need is 'randperm', not 'nchoosek'. The latter would give you all possible such choices, which is an awful lot of choices, namely 9,381,724,380 of them.
>
> For a single submatrix:
>
> p = randperm(140);
> submatrix = matrix(p(1:6),:);
>
> (If you need many such submatrices, repeat the above. If you are worried about the very remote chance of repetitions, test for and reject them.)
>
> Roger Stafford