Thread Subject: combinations of N matrixes taken K at a time

Subject: combinations of N matrixes taken K at a time

From: tirinacria CICCIOCICCIO

Date: 11 Oct, 2009 16:21:02

Message: 1 of 5

Hey I’m a new user.
I want to perform this:

I have 6 square matrixes A B C D E F
I want to find the possible combinations of these matrixes taken 3 at a time and calculate the product of the determiner of each combination
In order to find all possible combinations I can do this:
MAT={‘A’,’B’,’C’,’D’,’E’,’F’}
comb=nchoosek(MAT,3)
The results is:

comb =

    'A' 'B' 'C'
    'A' 'B' 'D'
    'A' 'B' 'E'
    'A' 'B' 'F'
    'A' 'C' 'D'
    'A' 'C' 'E'
    'A' 'C' 'F'
    'A' 'D' 'E'
    'A' 'D' 'F'
    'A' 'E' 'F'
    'B' 'C' 'D'
    'B' 'C' 'E'
    'B' 'C' 'F'
    'B' 'D' 'E'
    'B' 'D' 'F'
    'B' 'E' 'F'
    'C' 'D' 'E'
    'C' 'D' 'F'
    'C' 'E' 'F'
    'D' 'E' 'F'
Then I know all combinations

Now I want to create with a for cycle a matrix with like this:

Det=[|A|*|B|*|C| , | A|*|B|*D|,………]
How can I perform this multiplication?
The problem is that in the matrix comb, A is a text.
Please give me some advice
Thanks

Subject: combinations of N matrixes taken K at a time

From: Matt Fig

Date: 11 Oct, 2009 16:50:24

Message: 2 of 5

Store your matrices in a cell array, then use nchoosek with numeric arguments to index into the cell.

A = {rand(2) rand(2) rand(2)}
t = nchoosek(1:3,2)

G = cell(size(t,1),1);
for ii = 1:size(t,1)
    G = A(t,ii,1) * A(t,ii,2); % Or whatever here.
end

Subject: combinations of N matrixes taken K at a time

From: Matt Fig

Date: 11 Oct, 2009 16:56:04

Message: 3 of 5

Sorry, that should read:


A = {rand(2) rand(2) rand(2)}
t = nchoosek(1:3,2)

G = cell(size(t,1),1);
for ii = 1:size(t,1)
    G{ii} = A{t(ii,1)} * A{t(ii,2)}; % Or whatever here.
end

Subject: combinations of N matrixes taken K at a time

From: Bruno Luong

Date: 11 Oct, 2009 17:46:04

Message: 4 of 5

"tirinacria CICCIOCICCIO" <d.accorso@tin.it> wrote in message <hat0le$jeq$1@fred.mathworks.com>...

> The problem is that in the matrix comb, A is a text.

When you call nchoosek, you can supply any kind of arrays or cell arrays. Example:

A = rand(5);
B = rand(5);
C = rand(5);
D = rand(5);
E = rand(5);
F = rand(5);

allmystuff = {A B C D E F};

threestuff = nchoosek(allmystuff, 3);

% Each row of the result THREESTUFF is one combination

If you want to compute the product of determinants, then feed NCHOOSEK with the array of determinants of A, B, ..., F, then compute PROD of the result along the second dimension.

Bruno

Subject: combinations of N matrixes taken K at a time

From: tirinacria CICCIOCICCIO

Date: 11 Oct, 2009 17:59:03

Message: 5 of 5

thank you very much!

Tags for this Thread

Everyone's Tags:

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.

Tag Activity for This Thread
Tag Applied By Date/Time
l Bruno Luong 11 Oct, 2009 13:49:07
nchoosek tirinacria 11 Oct, 2009 12:24:04
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com