Design choice for iterating over a cell array
1 Comment
"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.
Accepted Answer
More Answers (1)
1 vote
4 Comments
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.
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!