A is a 1-dimensional array. I used to compute sum(abs(A)). But when I changed to the following, the speed increased nearly 10 fold. Why is that?

    sumA=0
    for i=1:length(A)
        sumA = sumA + abs(A[i])
    end

Reply via email to