how to extract 3rd dimensions of cells?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Afsaneh
el 3 de Jun. de 2015
Comentada: Walter Roberson
el 3 de Jun. de 2015
i have a cell array which in every cell i have a 3 dimensional matrix.(x,y,3)
now i want to extract 3rd dimension of all cells: (:,:,1)
how can i do that without using for loop?
thanks.
0 comentarios
Respuesta aceptada
Walter Roberson
el 3 de Jun. de 2015
ResultCell = cellfun(@(M) M(:,:,1), YourCellArray, 'Uniform', 0);
You might possibly want to
cat(3, ResultCell{:})
if you want the result as a 3D matrix stacking the individual layers, provided the individual layers are all the same size.
2 comentarios
Walter Roberson
el 3 de Jun. de 2015
In the case where all of the arrays have the same size, and you want the result as a stacked matrix, there is also
T = cat(4, YourCellArray{:});
Result = reshape(T(:,:,1,:), [size(T,1), size(T,2), size(T,4)]);
Más respuestas (0)
Ver también
Categorías
Más información sobre Resizing and Reshaping 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!