Automate splitting arrays to input into table
Mostrar comentarios más antiguos
I have an array that contains a total of 56 numbers. I need to take the first 14 numbers, the next 14 numbers, etc. and create a table with 14 columns and 4 rows. The below code works, but I would like to automate the process with a for loop or another method so I can repeat the same process on arrays that are much longer. Any suggestions?
array2table([means(1:14);means(15:28);means(29:42);means(43:56)])
Respuestas (2)
>> M = randi(9,1,56);
>> X = mat2cell(M,1,[14,14,14,14]);
>> X = cellfun(@(c)c(:),X,'uni',0); % this might not be required
>> T = cell2table(X)
Peter Perkins
el 13 de Feb. de 2017
0 votos
Use array2table, but use reshape(means,14,4) first.
Categorías
Más información sobre Matrices and Arrays en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!