Using indices of array to define indices of cell array
古いコメントを表示
If I am wanting to define certain elements in an array based on the indices of another array that meet a certain condition, I know how to do so. For example, if I have an array A, and I want to create an array B in which I define the elements of B that match those of A for which A>3 one way and the rest another, I know to do this:
B(A>3) = %definition
B(A<=3) = %other definition
However, what I am wanting to do is something similar, but for cell arrays. So, to use the same example, I want to define cells of C with the same indices as those of A that meet my condition, A>3. Is there a simple way to do so if loops need to be avoided? Note that A would still be an array in the scenario.
採用された回答
その他の回答 (1 件)
Honglei Chen
2012 年 2 月 1 日
Similar to what you did for vectors:
C{A>3}
カテゴリ
ヘルプ センター および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!