I would like to access vector elements like this:
a_new = [a(1:10) a(21:30) a(41:50) ... ]
Is there any elegant way how to do that without loops?
The vector is huge, so something like
for i=1:floor(length(a)/n) if mod(i,2)==0 kk=((i-1)*n):((i)*n); k=[k kk]; end; end;
cannot be used.
Assuming that the number of elements of your vector A is exactly divisible by 20:
M = reshape(A,20,) V = M(1:10,:) V = reshape(V,1,)
If required, pad/trim the vector A to make it a suitable length.