Splitting matrices into small matrices based on column values

1 Ansicht (letzte 30 Tage)
Yaser Khojah
Yaser Khojah am 28 Feb. 2018
Kommentiert: Bob Thompson am 1 Mär. 2018
I have two matrices, A and B where A is the name of each field and B is their corresponding productions as:
A = [3 2 1 10;
1 3 2 20;
2 3 1 30;
3 2 1 25;
1 3 2 10;
2 3 1 15]
and
B = [10 20 5 10;
4 6 20 20;
5 10 20 30;
20 10 30 25;
4 20 12 10;
10 30 20 15]
The last column of each matrix represents their profit and they are matching. For example, filed 3 runs at 10, field 2 at 20 and field 3 runs at 5 to make profit of 10. Now I want to create matrices which shows only the matching order of each fields such as x = [3 2 1 10; 3 2 1 25] and their corresponding productions as [10 20 5 10;20 10 30 25]. In my model A and B sizes are 200,000 rows and I need to see how the profit is changing for each fields order. So, the result will be
AA_fields = [3 2 1 10; 3 2 1 25]
AA_Rate = [10 20 5 10; 20 10 30 25]
This is for the case of (3 2 1) and the rest will follow the same way with different matrices.
  1 Kommentar
Bob Thompson
Bob Thompson am 1 Mär. 2018
You can try working with the unique() command. I personally haven't used it yet, so I don't know if it will find the different sets and mark the accordingly, or if it will simply find only values which appear once.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by