フィルターのクリア

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

8 ビュー (過去 30 日間)
Leo Simon
Leo Simon 2013 年 2 月 15 日
コメント済み: Matt Raum 2015 年 5 月 14 日
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 件のコメント
Matt Raum
Matt Raum 2015 年 5 月 14 日
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
MATLABPATH
C:\Users\raummatt\Documents\MATLAB
C:\MatLAB\R2011b\toolbox\matlab\demos
C:\MatLAB\R2011b\toolbox\matlab\graph2d
C:\MatLAB\R2011b\toolbox\matlab\graph3d
C:\MatLAB\R2011b\toolbox\matlab\graphics
...
However, if I run restoredefaultpaths and then call path again I now have:
>> restoredefaultpath
>> path
MATLABPATH
C:\MatLAB\R2011b\toolbox\matlab\audiovideo
C:\MatLAB\R2011b\toolbox\matlab\codetools
C:\MatLAB\R2011b\toolbox\matlab\datafun
...
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 7.13.0.564 (R2011b) on Microsoft Windows 7 Version 6.1 (Build 7601: Service Pack 1)

サインインしてコメントする。

採用された回答

Julian
Julian 2013 年 3 月 8 日
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 件のコメント
Leo Simon
Leo Simon 2014 年 11 月 20 日
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
/usr/local/MATLAB/R2014b/toolbox/local/restoredefaultpath;
matlabpath(strrep(matlabpath, userpath, ''))
for some reason, matlab won't let me do this. Could you suggest something that might work along these lines?

サインインしてコメントする。

その他の回答 (1 件)

Shashank Prasanna
Shashank Prasanna 2013 年 2 月 15 日
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 件のコメント
Julian
Julian 2013 年 3 月 8 日
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: 1.1.6.6 $ $Date: 2010/02/25 08:08:12 $ | and $Revision: 1.1.6.8 $ $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 2013 年 3 月 8 日
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.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeTime Series Objects についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by