【发布时间】:2011-02-25 12:16:25
【问题描述】:
我是 Matlab 的新手,正在尝试摆脱 Java/C++ 习惯。
问题是“我如何才能摆脱这些 for 循环。”
我尝试使用 nchoosek(n0,2) 摆脱其中一个循环,但出现了另一个问题。(nchoosek 的性能)
<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>
【问题讨论】:
标签: performance matlab for-loop combinations sparse-matrix