フィルターのクリア

Indexing and turning into column vector

4 ビュー (過去 30 日間)
AES
AES 2023 年 7 月 23 日
編集済み: James Tursa 2023 年 7 月 23 日
Is there a quick way to index into an array and then make it a column vector without reshaping? See below for example:
a = ones(5, 4, 3, 2)
%Works
aR = reshape(a(:, :, :, 2), 1, [])
%Any alternatives?
%a(:, :, :, 2)(:), etc
Thanks in advance

採用された回答

James Tursa
James Tursa 2023 年 7 月 23 日
編集済み: James Tursa 2023 年 7 月 23 日
Not really. It's going to be a two-step process no matter how you do it (without resorting to a mex routine, which isn't worth it IMO). The indexing you do above is a deep data copy, but the reshape is very quick and is not a deep copy, so I wouldn't worry about it. Just do what you are currently doing. Note that if you want a column vector output you should be doing reshape(a(:, :, :, 2), [], 1).

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by