Design choice for iterating over a cell array
1 Commento
"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.
Risposta accettata
Più risposte (1)
1 voto
4 Commenti
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.
Categorie
Scopri di più su Loops and Conditional Statements in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!