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

37 visualizaciones (últimos 30 días)
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 comentarios
Walter Roberson
Walter Roberson el 17 de Sept. de 2020
Close, Vasishta:
B = reshape(A(2,3,:), 1, 3);

Iniciar sesión para comentar.

Respuesta aceptada

Stephen23
Stephen23 el 17 de Sept. de 2020
B = reshape(A(2,3,:),1,[])

Más respuestas (0)

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by