Thread Subject: simple combinations using nchoosek

Subject: simple combinations using nchoosek

From: tirinacria CICCIOCICCIO

Date: 17 Oct, 2009 16:27:01

Message: 1 of 2

Hey!
I want to find all possible combinations among a series of matrices ( mat1, mat2, may3,.........matN), taken 4 at the time.
In order to do this I did as follow:
aa= input('how many matrices do you have?);
bb= input('how many matrices do you want in each combination?);
for ii=1:aa
A=input('name of the matrix');
Allmatrices(ii,:) = {A}
allcombinations=nchoosek(Allmatrices,bb)
end
and I get back all possible combinations, but I do not know the nave of the matrices.
what are, for example the matrices that form the second row?
The problem is that at the and I have a matrix like this:
    [31x1 double] [31x1 double] [31x1 double] [31x1 double]
    [31x1 double] [31x1 double] [31x1 double] [31x1 double]
    [31x1 double] [31x1 double] [31x1 double] [31x1 double]
    [31x1 double] [31x1 double] [31x1 double] [31x1 double]
………………………………………………………………
………………………………………………………………
But I’ve lost the names of the matrices.
A would like to get something like this:
 [mat A] [mat B] [mat B] [mat B]
[mat A] [mat B] [mat B] [mat D]
[mat A] [mat B] [mat B] [mat E]
[mat A] [mat B] [mat C] [mat D]
…………………………………………………………
Please help me.

Subject: simple combinations using nchoosek

From: Steven Lord

Date: 17 Oct, 2009 19:07:56

Message: 2 of 2


"tirinacria CICCIOCICCIO" <d.accorso@tin.it> wrote in message
news:hbcr8k$bf3$1@fred.mathworks.com...
> Hey!
> I want to find all possible combinations among a series of matrices (
> mat1, mat2, may3,.........matN), taken 4 at the time.

Just posting the same question over and over won't get you any new
information, in general. But in this case I'll give you a hint.

matrixnames = {'A', 'B', 'C', 'D'};
matrixnames([1 3 4 2])

But in this case, rather than having matrices named mat1, mat2, mat3, ...
you should use a cell array or an N-D array of matrices. See Q4.6 in the
newsgroup FAQ.

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us at files@mathworks.com