How to creat a pairwise comparison matrix using a for loop ?
조회 수: 19 (최근 30일)
이전 댓글 표시
i have this matrix:
A=[2 3
4 7
5 4
2 1];
I need to get the following comparasion matrix
B=[
2-4 3-7
2-5 3-4
2-2 3-1
4-5 7-4
4-2 7-1
5-2 4-1]
B=
-2 -4
-3 -1
0 2
-1 3
2 6
3 3
댓글 수: 0
채택된 답변
Jan
2021년 4월 22일
A=[2 3; ...
4 7; ...
5 4; ...
2 1];
idx = nchoosek(1:size(A, 1), 2);
B = A(idx(:, 1), :) - A(idx(:, 2), :)
추가 답변 (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!