Basically, I need to understand what this piece of code does (“blocks” is a vector):
len = length(blocks);
currsum = sum(abs(blocks(i:1:len)));
I know what the sum and abs does, it’s just the last part, I know it’s something to do with the loop, however, does it take a specific part of the vector and get the sum, or, does it sum the entire vector up?
Let’s break this into parts:
Create a vector
[i, i+1, i+2,.... len]. Recall that in Matlab the operatorvec(indexes)selects the elements of the vector that are found in indexes.Take the last k elements from the i’th up to the last.
Absolute value of the last k elements.
Sum of the absolute value of the last k elements.