MATLAB: Use of catsamples() to concatenate sequences for a neural network

catsamplesdivideblockdividefcndynamic neural net...dynamic neural networkmulti outputmulti-inputmultiple sequencesneural networktime series

I have developed a MIMO NARX network where I have multiple sequences (trials). Originally, I concatenated the data with one trial after the other to create "continuous" input and target time series. Because the data is not really continuous, I get a discontinuation between each concatenation. After some digging, I found these 2 links that talks about problem ( https://www.mathworks.com/help/nnet/ug/understanding-neural-network-toolbox-data-structures.html ) and the solution ( https://www.mathworks.com/help/nnet/ug/multiple-sequences-with-dynamic-neural-networks.html ). However I am having troubles implementing the catsamples() command based on how my data is setup.
For the inputs, I have a cell array of 3×30 where each column is a sequence of different length of [2X1] (2 inputs) and each row will be a different input series. I have different experimental conditions saved in 1 cell array but each will be tested separately as a single input series.
EMG =3×30 cell array
Columns 1 through 5
{1×134 cell} {1×137 cell} {1×133 cell} {1×134 cell} {1×136 cell}
{1×134 cell} {1×137 cell} {1×133 cell} {1×134 cell} {1×136 cell}
{1×134 cell} {1×137 cell} {1×133 cell} {1×134 cell} {1×136 cell}
Columns 6 through 10 ...
EMG{1, 1}{1, 1} = 1×134 cell array
Columns 1 through 5
[2×1 double] [2×1 double] [2×1 double] [2×1 double] [2×1 double]
Columns 6 through 10 ...
The output is just a 1×30 where each column is a sequence/trial and each cell has 2 target outputs.
Angle_Moment=1×30 cell array
Columns 1 through 5
{1×134 cell} {1×137 cell} {1×133 cell} {1×134 cell} {1×136 cell}
Columns 6 through 10 ...
Angle_Moment{1, 1}{1, 1} = 1×134 cell array
Columns 1 through 5
[2×1 double] [2×1 double] [2×1 double] [2×1 double] [2×1 double]
Columns 6 through 10 ...
All the examples I found of catsamples() have each sequence in a separate variables. How can I implement
x_mul = catsamples(x1,x2,x3,'pad');
but with all the sequences in one single cell array with 2 inputs/outputs? Should I set up my data differently? How?
Also, I am planning on dividing my data using
net.divideFcn ='divideblock';
with 70-20-10%. Does that means it will take the first 21 values of the {1×30}?
Please respond if you have insight in either of the 2 questions (catsamples or divideFcn).
Thank you,

Best Answer

catsamples( EMG_InputSeries{i,:},'pad'); % For EMG
catsamples( Angle_Moment_TargetSeries{:},'pad'); % For Ankle_Moment
This will create a 1x400s cell array with 2x30 cell inside each.
For default 'divideblock', it takes 70 percent of 400s time points for training. If needed to take 70% of the Q = 30, the mode must be changed to sample
net.divideMode = 'sample';
This will take 21 points from every of the 400s time points for training.