how to extract 3rd dimensions of cells?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Afsaneh
am 3 Jun. 2015
Kommentiert: Walter Roberson
am 3 Jun. 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 Kommentare
Akzeptierte Antwort
Walter Roberson
am 3 Jun. 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 Kommentare
Walter Roberson
am 3 Jun. 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)]);
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!