Generate consistent pairwise matrix

조회 수: 6 (최근 30일)
Konstantina Marra
Konstantina Marra 2020년 6월 27일
I have created the following function which creates a pairwise matrix:
function P=pairwise_matrix(S,n)
P=zeros(n,n);
for i=1:n
for j=1:n
if (i==j)
P(i,i)=1; % fill in the diag
elseif j>i % fill in the upper triangular array
P(i,j)=S(ceil(length(S).*rand(1,1)));
end %eof if
end % eof for j
end %eof for i
%fill in the lower triangular array
for k=2:n
for m=1:(k-1)
P(k,m)=1/P(m,k); %otherwise P(k,m)=inv(P(m,k));
end %eof k
end %eof m
endfunction
In another function I calculate the consistency ration, in order to drop the tables that are not consistent. Is there any way of generating consistent matrices in the first place, so that I don't have to drop them later? Could for example the line P(i,j)=S(ceil(length(S).*rand(1,1))); be written different to achieve that?

답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by