Arrange and merge cell data
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Isma_gp
el 14 de Sept. de 2016
Comentada: Walter Roberson
el 16 de Sept. de 2016
Hi,
I have a 3x3 cell as follows: [[1x40], [1x40], [1x40] ; [1x30], [1x30] ,[1x30] ; [1x50], [1x50] ,[1x50] ]
I would like to arrange the data, so that the final result is a 1x3 cell: [[3x40];[3x30];[3x50]]
I would like to do this without calling each cell specifically (in reality this is for a 20x20 cell)
Thanks
0 comentarios
Respuesta aceptada
Walter Roberson
el 14 de Sept. de 2016
arrayfun(@(col) vertcat(YourCell{:,col}), 1:size(YourCell,2), 'Uniform', 0)
2 comentarios
Walter Roberson
el 16 de Sept. de 2016
arrayfun(@(row) vertcat(YourCell{row,:}), (1:size(YourCell,1)).', 'Uniform', 0)
Más respuestas (1)
Stephen23
el 16 de Sept. de 2016
Editada: Stephen23
el 16 de Sept. de 2016
C = {...
rand(1,40),rand(1,40),rand(1,40);...
rand(1,30),rand(1,30),rand(1,30);...
rand(1,50),rand(1,50),rand(1,50)};
%
D = cellfun(@(c)vertcat(c{:}),num2cell(C,2),'UniformOutput',false);
and tested:
>> size(D{1})
ans =
3 40
>> size(D{2})
ans =
3 30
>> size(D{3})
ans =
3 50
0 comentarios
Ver también
Categorías
Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!