Clustering Calculating total value

조회 수: 1 (최근 30일)
Jess
Jess 2019년 6월 20일
댓글: Walter Roberson 2019년 6월 21일
Sir
I have an Input matrix 90X2 matrix and another matrix C 4005X4 .
The following steps need to be performed
  1. Initially I have to select the (1,1) value and (1,2) value of C and store it in C1(1x2 matrix)
  2. Next I have to select the (1,3) value and (1,4) value of C and store it in C2 (1x2 matrix)
  3. Next I have to find the difference between each row of the matrix and C1 and store it in X(90x2 matrix)
  4. Next I have to find the difference between each row of the matrix and C2 and store it in Y (90x2 matrix
  5. Then I have to add the row values of X and store it in A(90x1 matrix)
  6. Then I have to add the row values of Y and store it in B((90x1 matrix)
  7. Then I have to compare the values of A and B. If A is greater, then number 2 should be stored in matrix Z and the smaller number among A and B should be stored in matrix M, else number 1 should be stored in matrix Z and the smaller number among A and B should be stored in matrix M. Now we have got an 90x1 Z matrix with values of either 1 or 2 and a 90x1 P matrix with the smaller values among A and B.
  8. Now I have to find the sum of all values of M and store it in P.
  9. Next I have to carry out the same procedure with the value of (2,1) and (2,2) as C1 and (2,3) and (2,4) as C2.
  10. Likewise I have to carry out the operation for all 4005 values of C
  11. Finally I have to find the value of C1 and C2 for which the value of P is minimum
Kindly help me with this

답변 (1개)

Walter Roberson
Walter Roberson 2019년 6월 20일
C1 = C(1,1:2);
C2 = C(1, 3:4);
X = YourArray - C1;
  댓글 수: 2
Jess
Jess 2019년 6월 21일
Sir
I have to do it for all the 4005 combinations
How to do it?
Plz help
Walter Roberson
Walter Roberson 2019년 6월 21일
for loop. Possibly using a cell array.

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

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by