M=50
G= randi(100,100,2);
N = 100;
iS = zeros(M,M);
for i1 = 1:M
for i2 = 1:M
if i1 == i2
for g = 1:N
iS(i1,i2) = iS(i1,i2) + eq(i1,G(g,1))+eq(i2,G(g,2));
end
else
for g = 1:N
iS(i1,i2) = iS(i1,i2)-(eq(i1,G(g,1))*eq(i2,G(g,2))+eq(i1,G(g,2))*eq(i2,G(g,1)));
end
end
end
end
I am trying to implement this code efficiently in MATLAB. The run time seems to take too much time. Is there a way to implement this code efficiently?
G is a 1000*2 double array.