Please, how can I convert a Numeric Matrix (1400 lines/steps x 30 columns/features) to Cell Array (1400x1) Nx1 as required for LSTM training?
In this case, the 30 columns by line must be nested into the one cell array each line.
In outer view, cell array will be (1400x1), but when click on cell it will open as (1x30) containing the 30 features columns in one line.
Simplified example:
From (5x4) matrix A (lines: timesteps/observations, columns: input features data)
1 2 3 4
2 3 4 5
3 4 5 6
4 5 6 7
5 6 7 8
To (5x1) cell array C (Nx1 as requested by LSTM, N = steps) nesting features columns into the cell:
{1x4} => (1 2 3 4) inside line cell (1x4)
{1x4} => (2 3 4 5) inside line cell (1x4)
{1x4} => (3 4 5 6) inside line cell (1x4)
{1x4} => (4 5 6 7) inside line cell (1x4)
{1x4} => (5 6 7 8) inside line cell (1x4)
I can build it manually from an empty cell array by entering in each line cell and pasting data (30 columns) into them, but my data has 1400 lines.
The label (output) categorical vector (5x1 example) for the LSTM is ready (1400x1 real) and contains binary classification (0, 1) for each line as expected responses.
ANSWER
Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.
Use mat2cell(). Here is an example A = [ ...
1 2 3 4
2 3 4 5
3 4 5 6
4 5 6 7
5 6 7 8];
B = mat2cell(A, ones(size(A,1),1), size(A,2));
Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.
Use mat2cell(). Here is an example
A = [ ... 1 2 3 4 2 3 4 5 3 4 5 6 4 5 6 7 5 6 7 8]; B = mat2cell(A, ones(size(A,1),1), size(A,2));
Comments
Post a Comment