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

48 ビュー (過去 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 件のコメント
Walter Roberson
Walter Roberson 2020 年 9 月 17 日
Close, Vasishta:
B = reshape(A(2,3,:), 1, 3);
Brian
Brian 2020 年 9 月 17 日
Thank you for the solution :-)

サインインしてコメントする。

採用された回答

Stephen23
Stephen23 2020 年 9 月 17 日
B = reshape(A(2,3,:),1,[])

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by