Splitting matrices into small matrices based on column values
조회 수: 1 (최근 30일)
이전 댓글 표시
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
Bob Thompson
2018년 3월 1일
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.
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!