vendredi 14 février 2020

Alternative options for For loops in MATLAB [duplicate]

In my program, I use some form of for loops that result in high computational and time consuming difficulties. Some of them include two for loops that should satisfy some conditions as like as the following example:

for a=1:N
for b=1:N
    for c=1:N
        if W(b,c)~=0
            temp(c)=S(a,b)-S(a,c);
        end
    end
          sum_temp=max(temp)+sum_temp;

end
B(a,a)=sum_temp;
sum_temp=0;

end

How can improve efficiency?

Aucun commentaire:

Enregistrer un commentaire