MATLAB: How to collect individual bunches of data in a column of a matrix

matrix manipulation

Hi,
I have a matrix where I would like to collect the first 203 rows of a column into a variable, say e1, then skip the next 813 rows, then collect and add the next 203 rows into e1 again, then skip the next 813 rows… and so on until the end of the column.
I am new to MatLab and could not figure this out myself. Could someone suggest how to do this please?
Thanks

Best Answer

Assuming that the length of your column vector is a multiple of 203+813 (if not, what should be done for the last bit that is too short?), then a possible way is to reshape your vector into columns of 203+813 elements and only keep the first 203 rows before reshaping back into a column:
desired = reshape(yourcolumnvector, 203+813, []);
desired = reshape(desired(1:203, :), [], 1)
Another is to simply build the whole list of indices:
indices = (1:203)' + (0:numel(yourcolumnvector)/(203+813)-1) * (203+813);
desired = yourcolumnvector(indices)