Contents

catsamples

Concatenate neural network data samples

Syntax

catsamples(x1,x2,...,xn)
[x1 x2 ... xn]
catsamples(x1,x2,...,xn,'pad',v)

Description

catsamples(x1,x2,...,xn) takes any number of neural network data values, and merges them along the samples dimension (i.e., the matrix column dimension).

If all arguments are matrices, this operation is the same as [x1 x2 ... xn].

If any argument is a cell array, then all non-cell array arguments are enclosed in cell arrays, and then the matrices in the same positions in each argument are concatenated.

catsamples(x1,x2,...,xn,'pad',v) allows samples with varying numbers of timesteps (columns of cell arrays) to be concatenated by padding the shorter time series with the value v, until they are the same length as the longest series. If v is not specified, then the value NaN is used, which is often used to represent unknown or don't-care inputs or targets.

Examples

This code concatenates the samples of two matrix data values.

x1 = [1 2 3; 4 7 4]
x2 = [5 8 2; 4 7 6]
y = catsamples(x1,x2)

This code concatenates the samples of two cell array data values.

x1 = {[1:3; 4:6] [7:9; 10:12]; [13:15] [16:18]}
x2 = {[2 1 3; 5 4 1] [4 5 6; 9 4 8]; [2 5 4] [9 7 5]}
y = catsamples(x1,x2)

Here the samples of two cell array data values, with unequal numbers of timesteps, are concatenated.

x1 = {1 2 3 4 5};
x2 = {10 11 12};
y = catsamples(x1,x2,'pad')
Was this topic helpful?