Here is an example of a subset of the matrix I would like to use:
1 3 5 2 3 6 1 1 1 3 5 4 5 5 5 8 8 0
1 3 5
2 3 6
1 1 1
3 5 4
5 5 5
8 8 0
You can do it using just indexing:
a(:) = a(:) - a(3*floor((0:numel(a)-1)/3)+1).';
Of course, the 3 above can be replaced by any other number. It works even if that number doesn't divide the number of rows.
3