MATLAB: Problem with commdvbs2.slx model in 16a commdemos not on MATLAB search path

MATLABpathrehashsettool

Dear Support,
 
I don’t know if this is just my setup or a well known problem in R2016a, but many of the shipping examples in R2016a Communications System Toolbox do not run from the doc.
 
For example, these 3 examples won’t open up. I am sure there are many more examples with this same problem.
 
Error! Filename not specified.
 
Undefined function or variable
'commdvbs2'.
 
The reason appears to be that the path is missing to these files.
 
These files are in my *C:\MATLAB\R2016a\toolbox\comm\commdemos* directory but this directory is not on my path in 16a. Here is the relevant part of my 16a path:
 
Error! Filename not specified.
 
This directory is on my path in 16b and there is no problem opening these models in 16b from the doc. Only 16a is a problem.
Here is the relevant part of my 16b path.
 
Error! Filename not specified.
 
Is this just my setup or a widespread problem?
 
Thank you.
 
Kerry
 
 

Best Answer

I did some further digging, and from my understanding of your workflow, the most likely reason for seeing path deletions in your MATLAB search path could be due to multiple copies of "pathdef.m" on your search path.  When you have multiple copies of this file, MATLAB uses the first one found on its path to set all other search paths.
Try to issue the command:
>> which pathdef
And make sure that you only have one entry that is located in matlabroot\toolbox\local\.
As "pathdef.m" is automatically generated, it is entirely possible that somehow another copy of it is created and is located somewhere on your "userpath".  As "userpath" takes precedence over all other paths, if there is a corrupted version of "pathdef.m" on that directory, it could be the reason why you are missing those CST demo paths.
I will submit a feature request for consideration of merging search paths in MATLAB in future releases.  In the meantime, the only workaround to restore your missing paths while preserving your custom search paths would be the following:
  1. Make sure to delete all extra copies of "pathdef.m", leaving only the one inside matlabroot\toolbox\local\ intact.
  2. Save your current "pathdef.m" as a TXT file somewhere on your drive.  
  3. Restore default path on MATLAB and export a copy of the updated "pathdef.m" as TXT file somewhere on your drive
  4. Use an existing DIFF software (such as WinDIFF) to merge two files
  5. Overwrite the existing "pathdef.m" file with the merged version 
To open "pathdef.m", you may use the following command in MATLAB command window:
>> edit(which('pathdef'))