Design choice for iterating over a cell array
1 Kommentar
"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.
Akzeptierte Antwort
Weitere Antworten (1)
1 Stimme
4 Kommentare
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.
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!