%% Divide Array by Rows
% Create an array.

A = reshape(1:20,5,4)'

%
% Divide the rows of A so that the cell array contains two subarrays. Since the first element of rowDist is 1, the first cell of C contains the first row of A. The second element of rowDist is 3, so the next cell of C contains the next three rows of A. The sum of the elements of rowDist equals the number of rows of A.

rowDist = [1 3];
C = mat2cell(A,rowDist)

%
% Display the subarrays.

celldisp(C)

% Copyright 2018 The MathWorks, Inc.