Optimizing three nested loops with multiple calculation in MATLAB
问题 For the following code I want to optimize it using the pattern introduced in this solution. However, the problem is how to deal with referring to three nested loops in a single statement. Moreover, the condition is far different from that post. hint: W and S are NxN sparse double matrices. for i=1:N for j=1:N for k=1:N if W(j,k)~=0 temp(k)=S(i,j)-S(i,k); end end sum_temp=max(temp)+sum_temp; temp=0; end B(i,i)=sum_temp; sum_temp=0; end 回答1: In this situation I would opt against fully