필터 지우기
필터 지우기

Pairwise comparision matrix considering a permutation

조회 수: 3 (최근 30일)
Dan Ibarra
Dan Ibarra 2021년 4월 27일
댓글: Dan Ibarra 2021년 4월 29일
With the following code
A=[2 3;
4 7;
5 4;
2 1];
idx = nchoosek(1:size(A, 1), 2);
B = A(idx(:, 1), :) - A(idx(:, 2), :)
I get:
B = 6×2
-2 -4
-3 -1
0 2
-1 3
2 6
3 3
But, how can I get a comparision for a rows permutation? Not combination.

채택된 답변

Hyeokjin Jho
Hyeokjin Jho 2021년 4월 28일
A=[2 3;
4 7;
5 4;
2 1];
len = size(A,1);
idx(:,1) = repelem(1:len,len);
idx(:,2) = repmat(1:len,1,4);
B = A(idx(:, 1), :) - A(idx(:, 2), :)

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by