L = zeros(Nz1,Ny); for z1 = 1:Nz1 for y1 = 1:Ny AA6 = 0; for z2 = 1:Nz2 AA5 = 0; for z3 = 1:Nz3 AA4 = 0; for t1 = 1:Nt1 AA3 = 0; for t2 = 1:Nt2 AA2 = 0; for t3 = 1:Nt3 AA1 = 0; for x = 1:Nx S1 = (M(x,y1,z2,z3) .* log(M(x,y1,z2,z3) ./ N(x,t1,t2,t3))); S1(isnan(S1)) = 0; AA0 = H(z2,z3,y1) .* A(t1,z1) .* B(t2,z2) .* C(t3,z3) .* S1; AA1 = AA1 + AA0; end AA2 = AA2 + AA1; end AA3 = AA3 + AA2; end AA4 = AA4 + AA3; end AA5 = AA5 + AA4; end AA6 = AA6 + AA5; end L(z1,y1) = AA6; end end
MATLAB: Looking for a more elegant (less process-time consuming) code that obviates the external for loops.
for loopMATLAB
Best Answer