Effacer les filtres
Effacer les filtres

RESTOREDEFAULTPATH doesn't restore default path (rather restores user's path)

12 vues (au cours des 30 derniers jours)
Leo Simon
Leo Simon le 15 Fév 2013
Commenté : Matt Raum le 14 Mai 2015
The first sentence on the help screen for restoredefaultpath is
%RESTOREDEFAULTPATH Restores the MATLAB search path to installed products.
% RESTOREDEFAULTPATH sets the search path to include only folders for
% installed products from MathWorks. Use RESTOREDEFAULTPATH when you are
% having problems with the search path.
which is precisely what restoredefaultpath doesn't do. (In the good old days it did, but not any more.)
In fact, restoredefault calls $MATLAB/toolbox/local/userpath.m which prepends a user specific path to the path.
I presume this must be what MATHWORKS intended? Can't be a bug, since it's hardcoded into restoredefaultpath.m If so, (a) could mathworks please change the description of restoredefaultpath? (b) why? (c) is there a command that actually restores the default path? (d) if not, could future releases please add a flag to restoredefaultpath so that one can actually restore the default path?
Thanks, Leo
  1 commentaire
Matt Raum
Matt Raum le 14 Mai 2015
My problem with this function is that after calling restoredefaultpaths the folders on the path are sorted alphabetically, rather than their default sorting.
For example, after starting Matlab and calling path I get the following:
>> path
However, if I run restoredefaultpaths and then call path again I now have:
>> restoredefaultpath
>> path
Presumably the true default ordering has the more commonly accessed paths near the top, whereas, after everything is sorted alphabetically, matlab may spend more time searching for the right path for a common function.
Ordinarily, just saving the true default path somewhere and reloading it might work but I'm trying to write code that can be distributed to multiple users so I can't rely on them all having some file with the true default paths stored. Instead I need to rely on something like restoredefaultpaths. Is there any way to restore the default paths as well as the default path ordering that MatLAB uses when it is first started?
I'm running MATLAB Version (R2011b) on Microsoft Windows 7 Version 6.1 (Build 7601: Service Pack 1)

Connectez-vous pour commenter.

Réponse acceptée

Julian le 8 Mar 2013
Further to my comment (see above), the old behaviour can be had by
restoredefaultpath; matlabpath(strrep(matlabpath, userpath, ''));
Arguably the new behaviour of restoredefaultpath is what one would expect - it now returns the default path at start up, but excludes any dynamic or path saves by the user. It now matches the behaviour of the Default button in pathtool. The userpath is just 1 location, that is in the user area of a system and not subordinate to matlabroot.
  1 commentaire
Leo Simon
Leo Simon le 20 Nov 2014
Thanks julian. Since I rely heavily on really cleaning out the path---I need to be sure that my code is self-standing when I send it to others--- and won't remember that I need the added matlabpath command, what I'd like to do is have a restoredefaultpath command in my local userpath, which does something like
matlabpath(strrep(matlabpath, userpath, ''))
for some reason, matlab won't let me do this. Could you suggest something that might work along these lines?

Connectez-vous pour commenter.

Plus de réponses (1)

Shashank Prasanna
Shashank Prasanna le 15 Fév 2013
Hi Leo, Could you please forward this concern to MathWorks Technical Support via email/phone/web or Request Support button in the software. They may be able to give you a more fulfilling answer.
If this is a genuine change, it most likely captured in the Release Notes. I look through it but not exhaustively, since you haven't mentioned the two releases. But if it was intentional you should find the information here:
  3 commentaires
Julian le 8 Mar 2013
Hi, I am just trying the new R2013a, as of today! Our current company standard is R2011a as it happens and I can confirm the behaviour IS different. My R2011a restoredefaultpath does not prepend the default path with userpath, whereas the R2013a does do this. I happen to have both versions of restoredefaultpath in visdiff window and you can easily spot the change between | $Revision: $ $Date: 2010/02/25 08:08:12 $ | and $Revision: $ $Date: 2012/02/14 03:31:47 $ but the help in the file was NOT modified, nor are there any remarks in the release notes!
Shashank Prasanna
Shashank Prasanna le 8 Mar 2013
Hi Julian, Thanks for pitching in with the details. I really recommend forwarding any concern to support@mathworks.com especially if there have been any issues with its usage.

Connectez-vous pour commenter.


En savoir plus sur Time Series Objects dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by