Can someone help me in finding a way in arriving at the solution for the below problem.

3 visualizzazioni (ultimi 30 giorni)
I am trying to optimize the work flows in a manufacturing environment
Let A, B and C are continuous tasks, implies C is dependent of B and B on A.A,B and C combined is a single unit
let A could be finished in 2 or 3 or 4 days.denoted as an array below.
A=[1 2 3]
B=[4 5 6]
C=[7 8 9]
I want the complete list of POSSIBLE ways that I can take to finish the three tasks.
Output should look something like..
Column 1: Values of A matrix Column 2: Values of B matrix Column 3: Values of C matrix Column 4: Sum of the values in that particular row.
Possible scenarios
1 4 7 12(sum of the values)
1 4 8 13
1 4 9 14
1 5 7 13
1 5 8 14
1 5 9 15
Like we continue further the output will be
1 6 7 14
1 6 8 15
1 6 9 16
2 4 7 13
2 4 8 14
2 4 9 15
3 4 7 14
3 4 8 15
3 4 9 16
  4 Commenti
Suneel Kumar
Suneel Kumar il 30 Giu 2016
Modificato: Walter Roberson il 30 Giu 2016
Yes, Tran. A is column 1, B col 2 and C col 3. I want the list of possible cases with the matrices A, B and C.
Like we continue further the output will be
1 6 7 14
1 6 8 15
1 6 9 16
2 4 7 13
2 4 8 14
2 4 9 15
3 4 7 14
3 4 8 15
3 4 9 16

Accedi per commentare.

Risposta accettata

Guillaume
Guillaume il 30 Giu 2016
Modificato: Guillaume il 30 Giu 2016
You're asking for the cartesian product of A, B and C. There are entries for it in the file exchange, e.g. ALLCOMB, or you can do it easily with ndgrid:
A=[1 2 3];
B=[4 5 6];
C=[7 8 9];
[ca, cb, cc] = ndgrid(A, B, C);
allcombs = [ca(:), cb(:), cc(:)]
The sum is then trivial to obtain:
allcombswithsum = [allcombs, sum(allcombs, 2)]

Più risposte (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by