Explanation

Using exist with one argument means if MATLAB does not find that argument immediately, it must search all categories to which that argument might belong. This can be time consuming.


Suggested Action

To speed up the search and make your code more readable, specify a second argument to the exist call to indicate the category to which the first argument belongs. Valid values are: 'builtin', 'class' (for Java classes), 'dir', 'file', and 'var'.