Generate consistent pairwise matrix

8 Ansichten (letzte 30 Tage)
Konstantina Marra
Konstantina Marra am 27 Jun. 2020
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?

Antworten (0)

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by