Generate consistent pairwise matrix

13 次查看(过去 30 天)
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