Convert data to standard neural network cell array form


[y,wasMatrix] = tonndata(x,columnSamples,cellTime)


[y,wasMatrix] = tonndata(x,columnSamples,cellTime) takes these arguments,


Matrix or cell array of matrices


True if original samples are oriented as columns, false if rows


True if original samples are columns of a cell array, false if they are stored in a matrix

and returns


Original data transformed into standard neural network cell array form


True if original data was a matrix (as apposed to cell array)

If columnSamples is false, then matrix x or matrices in cell array x will be transposed, so row samples will now be stored as column vectors.

If cellTime is false, then matrix samples will be separated into columns of a cell array so time originally represented as vectors in a matrix will now be represented as columns of a cell array.

The returned value wasMatrix can be used by fromnndata to reverse the transformation.


Here data consisting of six timesteps of 5-element vectors, originally represented as a matrix with six columns, is converted to standard neural network representation and back.

x = rands(5,6)
columnSamples = true; % samples are by columns.
cellTime = false;     % time-steps in matrix, not cell array.
[y,wasMatrix] = tonndata(x,columnSamples,cellTime)
x2 = fromnndata(y,wasMatrix,columnSamples,cellTime)
Was this topic helpful?