Effacer les filtres
Effacer les filtres

How can I index a 3D array like A(n,m,:) and get the result as a 1D array?

32 vues (au cours des 30 derniers jours)
Brian
Brian le 17 Sep 2020
Commenté : Brian le 17 Sep 2020
Hi
Assume we have a 3D array like this (image from the manual):
In python/numpy I can something similar to
B = A(2,3,:)
which gets me B as a 1D array with: B = [A(2,3,1), A(2,3,2) , A(2,3,3)]
Can I do something similar (as simple) in matlab without going to e.g. linear indexing?
  3 commentaires
Walter Roberson
Walter Roberson le 17 Sep 2020
Close, Vasishta:
B = reshape(A(2,3,:), 1, 3);
Brian
Brian le 17 Sep 2020
Thank you for the solution :-)

Connectez-vous pour commenter.

Réponse acceptée

Stephen23
Stephen23 le 17 Sep 2020
B = reshape(A(2,3,:),1,[])

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Indexing 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!

Translated by