matlab - Make sure nested loop variables have different values -
i want create adjacency matrix metric matrix in matlab. programme follow:
function [v] = adjacency(z) n= size(z,1); v = zeros(n); k=1:n; = 1:n j = 1:n if z(i,j)<= max(z(i,k),z(j,k)) v(i,j)=1; v(j,i)=1; else v(i,j)=0; v(j,i)=0; end end end end
i don't know how create status k
must different i
, different j
.
for k=1:n; = 1:n j = 1:n if(~(k==i || k==j)) if z(i,j)<= max(z(i,k),z(j,k)) v(i,j)=1; v(j,i)=1; else v(i,j)=0; v(j,i)=0; end end end end end
matlab for-loop adjacency-matrix
No comments:
Post a Comment