Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: nchoosek all pairwise combinations
Replies: 10   Last Post: Nov 27, 2012 7:46 AM

 Messages: [ Previous | Next ]
 Jos Posts: 1,268 Registered: 10/24/08
Re: nchoosek all pairwise combinations
Posted: Nov 27, 2012 5:29 AM

"Nasser M. Abbasi" <nma@12000.org> wrote in message <k922jf\$sn9\$1@speranza.aioe.org>...
> On 11/27/2012 3:40 AM, Jos (10584) wrote:
>

> > A very easy way to obtain the interactions would be using NDGRID
> >
> > A = 'abcde'
> > [B1, B2] = ndgrid(A)
> >
> > which stores the interactions in two separate yet related matrices ...
> > It all depends on what you want to do with the result!
> >
> > ~ Jos
> >

>
> Yes, good, but the problem is that the result are
> all one long string now (in B1 and B2) and there will need to be much more
> work done to go from those to the final result the OP wanted,
> which is a cell matrix of only 2 chars/per string in each entry.
>
> --Nasser
>
>

I did not see the word cell matrix in the OP message ...

but "much more work" is rather overstated:

A = 'abcde'
[B1, B2] = ndgrid(A)
M = reshape(cellstr([B1(:) B2(:)]),5,5)

~ Jos

Date Subject Author
11/26/12 Jerry
11/27/12 Nasser Abbasi
11/27/12 Nasser Abbasi
11/27/12 Nasser Abbasi
11/27/12 Jos
11/27/12 Nasser Abbasi
11/27/12 Jos
11/27/12 Nasser Abbasi
11/27/12 Jos
11/27/12 Nasser Abbasi
11/27/12 Jos