-
8 Comments
But in tests #7 and #8 too, the subscript index is neither a positive integer nor a logical value; so why does it not lead to the same subscript indexing error that invokes the 'catch' statement?
Tests #7 and 8 involved an 0*0 array [] as the index, which is an extreme case where MATLAB returns nothing without issuing any error. Since no error occurs in the try block, the program flow does not enter the catch block. Hope this helps.
Thanks, Peng Liu! I would have expected that [] as an index of a cell variable would lead to an error, but apparently MATLAB accepts it and produces a comma-separated list of zero terms (which I now realize is apparently different from an empty matrix, otherwise it would have assigned "ans = [];"). Anyway, again, thanks for your comments, it really helped me understanding MATLAB better!
Suggested Problems
-
3891 Solvers
-
Deleting an element in a matrix
472 Solvers
-
196 Solvers
-
5531 Solvers
-
252 Solvers
More from this Author1
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!