Creating a general Product-Operations Matrix with the help of loops
    조회 수: 12 (최근 30일)
  
       이전 댓글 표시
    
Hi all,
I am currently working on a way to create a Product-Operations Matrix which should look something like this: Columns: listing all Products Rows: all operations needed for all products
So for example M(1,3)=1 and M(4,3)=1 means Product 3 is produced using Operations 1 and 4.
The idea is to analyse this Matrix in a later stage in order to find Products that have similar operations.
Right now, I have used MS Access to export the Operations for each Product, the Table looks like this:
ProductNo. OperationID OperationTime
  1 A 0.1
  1 C 0.3
  1 D 0.4
  1 E 0.5
  2 A 0.1
  2 B 0.6
  3 E 0.5
  3 A 0.1
I would like to create according Matrix that looks like this:
0.1 0.1 0.1
0 0.6 0
0.3 0 0
0.4 0 0
0.5 0 0.5
I guess I have to use many for-loops, but I just cannot wrap my head around it... Thank you so much for your help!
댓글 수: 0
답변 (1개)
  Kevin Gleason
    
 2016년 11월 2일
        I would suggest you create a helper function as follows:
% Get the index of a letter A=1, B=2, ..., E=5
letterIdx = @(letter) letter-'A' +1;
This will correlate whatever letter is in Column 2 (OperationID) to an index in the final matrix. Next we can create a matrix of zeros in the size of your data:
prodOps = zeros(5,3);
Finally you can populate your "prodOps" matrix by using a single loop over every row of your data and fill in "prodOps" as follows:
prodOps(col1, letterIdx(col2)) = col3;
댓글 수: 0
참고 항목
카테고리
				Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

