How to access specific data in a cell array

2 ビュー (過去 30 日間)
Behshad
Behshad 2022 年 12 月 6 日
編集済み: Jan 2022 年 12 月 6 日
hello all,
Suppose there is a cell array like {F}1×N, where each cell contains a matrix such as F{1}10×4, F{2}11×4, F{3}12×4, ... . Now I want to access some rows in each of the cells (for instance in this way F{1:end}(2:2:end,:)) and finally, Convert them into an ordinary array by cell2mat.
Are there any ways that I can access the data without using a loop or cellfun?
Thank you in advance,
Behshad

採用された回答

Jan
Jan 2022 年 12 月 6 日
編集済み: Jan 2022 年 12 月 6 日
No. Cell arrays need to be accessed in a loop for this case. You can hide the loop using cellfun, but this runs a loop internally also, such that a simple for loop is faster usually.
By the way: Why do you want to avoid the loop? The memory transfers are the expensive part of the procedure and a vectorization does not reduce the work.

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by