Q:

Subsetting a rectengular matrix

I have a 5139 x 30 matrix and wonder how can I split it into 39 subsets in a for loop condition in MATLAB.
My goal:
The first subset will have 132 rows & all columns. The second subset has 132+132 rows & all columns, and the third subset has 132+132+132 rows & all columns.
This will go on until 5139 rows is reached.
Thank you.

A:

According to your comment, I believe that the code following could achieve your goal:
%%generate the data and find the boundary of the data
Data=rand(5139,30);
[m,~]=size(Data);

%%calculate the index of every subset and split the data
L=1;
R=132;
Subset=cell(39,1);
for ii=1:39
  Subset{ii}=Data(L:R,:);
  R=R+132;
  R=min(R,m);
end

Edit: thanks @CrisLuengo 's useful comment which adds the readability of the code.

