MATLAB: >40 seconds waiting for Undefined function or variable error 2017b

2017berrorfindunlicensedfunctionslong wait timeundefined function or variable

I'm using matlab 2017b on a windows 7 64 bit machine and when I accidentally reference a variable or function that doesn't exist, Matlab consumes a significant amount of time in 'busy' mode before throwing the error: 'Undefined function or variable'. I've paused the execution a few times to see where the bottleneck is and it has always opened the findUnlicensedFunctions() function. To cause this error, I type in any nonsense command such as "ttt" in the command window where ttt does not refer to any function or variable. Using tic/toc just before and after the call to ttt resulted in 43 seconds waiting for the error. Is anyone else experiencing this or might it be specific to my environment? I upgraded last week from 2016a and did not have this problem before.

Best Answer

Apparently when a variable or function is called but not available, matlab searches network locations on the matlab path and if those connections are no longer accessible, this delay occurs. To confirm that this is what's causing the unbearably long deley, I turned off/on my internet connection(s) and the problem vanished when there wasn't a connection but immediately returned when there was a connection. The link below contains suggestions on how to troubleshoot this issue but doesn't fix it for good.
[UPDATE]
After dealing with the same problem off and on for years, I wrote a function that fixes it. The function below creates a GUI that lists all network drives that appear in your Matlab history. You can select any (or all) of the drives that you no longer have access to and it will remove those from your history. The effect was immediate for me and I no longer had to deal with the wait time. Other options in the GUI allow you to restore the history from a backup if needed. It's a pretty simple.
If you're interested (and if you're a PC user) please give it a shot and let me know if it works for you, too.
Related Question