converting 3d matrix into a cell array
Mostra commenti meno recenti
Hi,
I have a 3D matrix (1001x 259x 259) and want to convert to a cell array (1x1001) in which each cell array has 259x259 matrix (2D matrix). Could anyone help?
Thanks.
1 Commento
AT_HYZ
il 22 Mar 2024
Risposta accettata
Più risposte (1)
James Tursa
il 22 Mar 2024
Modificato: James Tursa
il 22 Mar 2024
x = rand(1001,259,259);
result = arrayfun(@(k)squeeze(x(k,:,:)),1:size(x,1),'uni',false);
size(result)
size(result{1})
But, be advised that for matrix manipulation it might be better to keep this data as a 3D array with dimensions 259x259x1001 (i.e., permute(x,[2 3 1])) so that you can take advantage of the page functions like pagemtimes, pagemldivide, etc.
Categorie
Scopri di più su Linear Algebra in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!