I have a matrix x, with x = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 …]'.
I now want a for loop or any vectorised form, so that I can store the elements c = [7 8 9 12 13 14 17 18 19…].
A for loop would then look something like:
for p = [7:1:9],[12:1:13]... %do some calculations
end
x is quite a large vector (2400 entries) and I do not want to specify the terms in the square brackets for the entire matrix. Is there a way to change the index of the for loop, so that it can incremetnt between 1 and 3 as shown above?
Kind regards
Pascal
Best Answer