0
我是Matlab的新手,并试图摆脱Java/C++习俗。
问题是“我如何摆脱这些循环。”
我试图用nchoosek(n0,2)摆脱循环的一个,但另一个问题出现了。(nchoosek的性能)Matlab摆脱循环
<Matlab code>
for j=2:n0
for i=1:j-1
%wij is the number of rows of A that have 1 at both column i and column j
%summing col i and j to find #of common 1's
wij = length(find((A(:,i)+A(:,j))==2));
%store it
W(1,j)=wij;
%testing whether the intersection of any two columns is too large
if wij>= (1+epsilon)*u2;
%create and edge between col i j
end
end
end
</matlab Code>