MATLAB: Does the installed support package stop working after restarting MATLAB

MATLAB

I installed the Support Package for USB Webcams in 2016b. It worked flawlessly, and then I closed and re-opened MATLAB. Now I get the error
"MATLAB Support Package for USB Webcams has not been installed. Open Support Package Installer to install the Webcam Support Package."
If I open the Add-On Explorer it's there, marked as "installed". Any idea what's going on here?

Best Answer

When you install a support package, MATLAB attempts to add the necessary directories to your path. However, if your pathdef.m (path definition file) is read-only, it probably failed to save the updated path. That means the path is active until you restart MATLAB.
Try this:
which -all pathdef
  • If there is only one, it is most likely in your MATLAB installation directory, and it is a read-only file.
  • If you have more than one, check each of them to see whether the path to the support package is included in one and not included in the other. The one that shows up first in the list is the one that is used by MATLAB, so make sure that file includes the necessary paths.
After you start MATLAB, try adding these paths and see if that fixes things:
addpath('C:\ProgramData\MATLAB\SupportPackages\R2016b\toolbox\matlab\webcam\supportpackages');
addpath('C:\ProgramData\MATLAB\SupportPackages\R2016b\toolbox\matlab\webcam\supportpackages\webcamexamples');
If it does, you can either update your pathdef.m to include those directories, or you can create a <https://www.mathworks.com/help/matlab/ref/startup.html startup.m>file and put it in your MATLAB home directory (output of userpath), and add those commands to that file.