Create similar matrices from another matrix

Hello everyone could anyone help me for my problem... I have two original matrices say amatrix and bmatrix that should be separated to four matrices say , each original matrix converted to 2 matrices. For example amatrix converted to c1h1 and c2h1. But bmatrix will converted to c1h2 and c2h2. The first condition here is c1h1 and c1h1 should be similar as much as we can. and the same for c2h1 and c2h1.the second condition that each matrix doesn't have more than 10 number and we shouldn't select single number to assign but entire row. For example.: amatrix =[5 5 0 0 0 0;6 1 0 0 0 0;2 2 2 2 2 2]; bmatrix =[5 5 0 0 0 0 0;5 1 5 0 0 0 0;2 2 2 2 4 6 6; 6 6 6 6 1 1 0] The expected solution is C1h1=[5 5 ;6 1] C1h2=[5 5 0 0 0 0;6 6 6 6 1 1] C2h1 =[2 2 2 2 2 2] C2h2=[2 2 2 2 4 6 6; 5 1 5 0 0 0 0] may be another solution is feasible. note it's not important to select every row have same number it's enough to have same number in c1h1 and c1h2 as shown for number 5 appears two times . I hope I could explain my problem clearly. Thanks for any help

댓글 수: 8

akshat gupta
akshat gupta 2020년 6월 26일
what do yo mean by "c1h1 and c1h1 should be similar as much as we can" ?
Rik
Rik 2020년 6월 26일
Your explanation is a bit difficult to follow. Can you explain for your example step by step why the results are as you describe?
That if c1h1 has numbers 3,4,5 ,we try to select rows from bmatrix that contains 3,4,5 to assign in c1h2 . c1h1 and c1h2 have similar rows. For example if c1h1 =[1 2 2 2 0 0; 6 6 6 0 0 0]; We expect that c1h2 will equal [6 6 1 1 0 0; 2 2 2 2 2 0] these rows extracted from original matrices
Ok Rik First i compare first row in first matrix amatrix with every row in bmatrix if any number in the row of amatrix exist in row of bmatrix , I will select these two rows and assign them to c1h1 and c1h2 respectively. In above example first row of amatrix is 5 5 (two 5) when looking in bmatrix we will found row 1 and row 3 contains 5 (two five in both) then select anyone of them and c1h1 =[5 5;.....]and c1h2=[5 5 ; .....] and so on for each row in amatrix the condition that c1h1 doesn't exceed 10(10 means number not sum. 5 5 is two not ten) I hope I could clear it and thanks
To try to bring some clarity to this...
amatrix =[5 5 0 0 0 0;6 1 0 0 0 0;2 2 2 2 2 2]
bmatrix =[5 5 0 0 0 0 0;5 1 5 0 0 0 0;2 2 2 2 4 6 6; 6 6 6 6 1 1 0]
%The expected solution is
C1h1=[5 5 ;6 1]
C1h2=[5 5 0 0 0 0;6 6 6 6 1 1]
C2h1 =[2 2 2 2 2 2]
C2h2=[2 2 2 2 4 6 6; 5 1 5 0 0 0 0]
amatrix =
5 5 0 0 0 0
6 1 0 0 0 0
2 2 2 2 2 2
bmatrix =
5 5 0 0 0 0 0
5 1 5 0 0 0 0
2 2 2 2 4 6 6
6 6 6 6 1 1 0
C1h1 =
5 5
6 1
C1h2 =
5 5 0 0 0 0
6 6 6 6 1 1
C2h1 =
2 2 2 2 2 2
C2h2 =
2 2 2 2 4 6 6
5 1 5 0 0 0 0
But other than that, I think you'll have to wait for Walter. He's the only one with the Mind Reading Toolbox. Why do you want to do this quirky thing anyway? What is the use case (context)???
My problem is assigning machines to cells(cells means places) in different periods. amatrix is the machines needed in period 1 and bmatrix is the machines needed in period 2 . We have two places in which machines are assigned. So c1h1 the same place of c1h2 in the two periods. Hence we need to reduce removing machines from period 1 and adding another machines to period 2. So if c1h1 has machines 3 and 4 we hope to remain them in their places to use in period 2 and not removing them and move to c2 h2 and adding them it is costly.
I hope this help 1st image

댓글을 달려면 로그인하십시오.

답변 (1개)

Hamdia Mansour
Hamdia Mansour 2020년 6월 28일

0 개 추천

Could anyone help here

댓글 수: 3

Your explanation of what should go into which matrix does not make any sense to me.
Do you see the attached photos All the problem around assignment problem. Assigning machines to departments in different periods. So we need to make machines in department 1 in the first period similar to whose in the second period in same department. Thanks for any help
Could you have a look at my code. It's working well for many examples but in some examples give incorrect solutions. If you don't mind to see the file and help me. Thanks in advance

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

질문:

2020년 6월 26일

댓글:

2020년 6월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by