repeat the same function on multiple variables/handles
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
i have 20 handles that I set to enable on, i.e. set(handle,'enable','on') and the same thing with off.
Is there a more efficient way to do this than using the set function 20 times? For example, is there a way to pass a list of the handles to a function that will repeat a function over the entire list?
0 commentaires
Réponse acceptée
dpb
le 13 Mar 2014
set accepts a handle vector and operates on each. Just use the array form. Note the property name and value can be cell arrays as well. See
doc set % for details
2 commentaires
dpb
le 13 Mar 2014
Sure...almost every Matlab builtin is vectorized. And, you can write your own functions in almost every case to also use vectors/arrays as inputs and generate same.
Looks like you need to go to the documentation and start at the "Getting Started" section and work through the examples of how Matlab works to get a feel for using it.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!