RESTOREDEFAULTPATH doesn't restore default path (rather restores user's path)
조회 수: 10 (최근 30일)
이전 댓글 표시
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
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
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개)
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
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
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 Exchange에서 File Operations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!