Transform a 3D dimension array to n 2D matrix
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hiua Daraei
am 24 Jul. 2019
Kommentiert: Stephen23
am 28 Jul. 2019
How can I transform a 3D dimension array (15*781*81) to 15 extracted 781*81 2D matrix to make it feasible to write down them in different Excel files?
Cheers,
Hiua
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 24 Jul. 2019
result = cellfun(@squeeze, num2cell(YourArray, [2 3]), 'uniform', 0)
This will give you a 15 x 1 cell array, each entry of which is a 781 x 81 array
2 Kommentare
Akira Agata
am 24 Jul. 2019
Another possible way:
result = arrayfun(@(k) squeeze(YourArray(k,:,:)),1:15,'UniformOutput',false);
This will also give you the same result as Walter-san's answer.
Weitere Antworten (1)
Stephen23
am 24 Jul. 2019
"How can I transform a 3D dimension array (15*781*81) to 15 extracted 781*81 2D matrix to make it feasible to write down them in different Excel files?"
There is no point in creating a separate cell array with duplicates of all of the data.
Simply loop over the array and save it as you go:
A = your 15x781x81 array
for k = 1:size(A,1)
M = permute(A(k,:,:),[2,3,1]);
... save M here
end
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!