Problem with assigning subset of multidimensional array
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
If there is a multidimensional array, say A= rand(3,4,2,2), it is easy to assign, say, the first page with B = A(:,:,1,:), using the colon operator. My problems: (1.) I dont know beforehand the number of dimensions ndim(A) of A and (2.) also not the dimension, in which the assignment will be. So in another case it might be the first row of a 3D-array which has to be assigned A(1,:,:).
Facing the 2. problem, I would use 'permute' or 'shiftdim' to place the dimension, where the assignment should be, to, say, the first dimension. For the example above: A = rand(3,4,2,2); A = shiftdim(A,2); % formerly 3.Dim is now on 1.position
But the 1. problem of unknown number of dimensions stay unsolved. Is there anybody who has an idea? Every help is appreciated.
Alex
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Matrices and Arrays dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!