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

조회 수: 49 (최근 30일)
Brian
Brian 2020년 9월 17일
댓글: Brian 2020년 9월 17일
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
Brian
Brian 2020년 9월 17일
Thank you for the solution :-)

댓글을 달려면 로그인하십시오.

채택된 답변

Stephen23
Stephen23 2020년 9월 17일
B = reshape(A(2,3,:),1,[])

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by