Design choice for iterating over a cell array
1 commentaire
"Is there any good reason why the language was designed this way?"
Consistency. All arrays can be iterated over, and for all arrays the index variable is one element (or one column) of that array, no matter what class. People often forget that for actually loops over the columns, which would lead to awkward bugs/inconsistencies/... if the contents of cell arrays were returned in the index.
Réponse acceptée
Plus de réponses (1)
1 vote
4 commentaires
And if you really want to, you can always insert the line below, just after your for statement (which suppresses the warning as well).
x=x{1};%#ok
Is that a setting buried somewhere deep? Because for me it doesn't offer to hide the warning, it just suggests it as a possible course of action.
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!