MATLAB Answers

Installed add-on stops working after restarting MATLAB

25 views (last 30 days)
Jeffrey Klein
Jeffrey Klein on 31 Jan 2018
Answered: Jay Vaidya on 4 Sep 2020
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?

  0 Comments

Sign in to comment.

Answers (2)

Benjamin Kraus
Benjamin Kraus on 1 Feb 2018
Edited: Benjamin Kraus on 1 Feb 2018
I believe 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.
You should have seen some error or warning text on the screen when you installed the support package indicating that the installer failed to save the updated path.
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 answer, 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.

  3 Comments

Benjamin Kraus
Benjamin Kraus on 1 Feb 2018
When I ran the installer, I got this warning message:
Warning: Unable to save path to file 'C:\Program Files\MATLAB\R2016b\matlab\toolbox\local\pathdef.m'. You can save your path to a different location by calling SAVEPATH with an input argument that specifies the full path. For MATLAB to use that path in future sessions, save the path to 'pathdef.m' in your MATLAB startup folder.
The two directories that were added to my path were these:
C:\ProgramData\MATLAB\SupportPackages\R2016b\toolbox\matlab\webcam\supportpackages
C:\ProgramData\MATLAB\SupportPackages\R2016b\toolbox\matlab\webcam\supportpackages\webcamexamples
After you start MATLAB, try adding those 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 startup.m file and put it in your MATLAB home directory (output of userpath), and add those commands to that file.
Jeffrey Klein
Jeffrey Klein on 1 Feb 2018
Thanks -- this is clearly the issue, when I run those last two lines it works.
Adding them to a startup.m file is easy enough, but I did have some trouble getting them added to pathdef.m. I did it like this, at the bottom of the p array (I'm showing the two lines before I added):
matlabroot,'\toolbox\rtw\targets\xpc\xpc\xpcmngr;', ...
matlabroot,'\toolbox\rtw\targets\xpc\xpcdemos;', ...
'C:\ProgramData\MATLAB\SupportPackages\R2016b\toolbox\matlab\webcam\supportpackages;', ...
'C:\ProgramData\MATLAB\SupportPackages\R2016b\toolbox\matlab\webcam\supportpackages\webcamexamples;', ...
With this configuration, when I call webcam, I don't get an error, but it doesn't actually work and just returns an empty array.
Benjamin Kraus
Benjamin Kraus on 1 Feb 2018
I personally prefer the startup.m approach, but be careful because that will apply to all versions of MATLAB (when you upgrade, you will need to modify startup.m to make sure you don't accidentally load the R2016b add-on to a newer release). If you want to get clever, you can use version or verLessThan to make sure the path is only modified for a specific version.
If you modify pathdef.m, I would add the path to the top of the p array, not the bottom, so that they shadow any other files with the same name. I'm not familiar enough with the USB Webcam add-on to know why it would return an empty array, but I suspect adding the path at the top of the pathdef.m will resolve the issue.

Sign in to comment.


Jay Vaidya
Jay Vaidya on 4 Sep 2020
Please try to run the following in the MATLAB Command Window:
>> opengl software
And then try opening the Add on explorer again. It worked for me.
If that works, you can save the preference so that MATLAB always opens with Software OpenGL by running:
>> opengl('save','software')

  0 Comments

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!