Using indices of array to define indices of cell array
Afficher commentaires plus anciens
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.
Réponse acceptée
Plus de réponses (1)
Honglei Chen
le 1 Fév 2012
Similar to what you did for vectors:
C{A>3}
Catégories
En savoir plus sur Logical dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!