I want my code to run faster and this section seems like its making the code run slower.
I tried to vectorize it and use meshgrid but couldn't figure it out.
%generate all noma node combinations with packets
combinations_withpackets=[];
for i=1:N
for j=1:N
if(i~=j)
for k=1:N
if((k~=i)&&(k~=j))
if((packets(i,j)>0)&&(packets(i,k)>0))
combinations_withpackets=[combinations_withpackets;i j k];
end
end
end
end
end
end
This is supposed to create an array of the form [i j k] where i, j and k are nodes, and at each row of the array they are not equal to each other.
It adds an [i j k] combination to combinations_withpackets if there are packets from node i to j and node i to k.