home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l460 / 2.ddi / GENERAL.DI$ / PATH.M < prev    next >
Encoding:
Text File  |  1993-03-07  |  1.5 KB  |  53 lines

  1. function p = path(a,b)
  2. %PATH    Control MATLAB's directory search path.
  3. %    PATH, by itself, prettyprints MATLAB's current search path.
  4. %    The search path list originates as the environment variable
  5. %    MATLABPATH in the underlying operating system, or is set by
  6. %    MATLABRC, and is perhaps individualized by STARTUP.
  7. %
  8. %    P = PATH returns a string containing the path in P.
  9. %    PATH(P) changes the path to P.
  10. %    PATH(P1,P2) changes the path to the concatenation of the
  11. %    two path strings P1 and P2.  Thus PATH(PATH,P) appends
  12. %    a new directory to the current path and PATH(P,PATH)
  13. %    prepends a new path.
  14. %
  15. %    For example, the following statements add another directory
  16. %    to MATLAB's search path on various operating systems:
  17. %
  18. %      Unix: path(P,'/home/myfriend/goodstuff')
  19. %      VMS:  path(P,'DISKS1:[MYFRIEND.GOODSTUFF]')
  20. %      DOS:  path(P,'TOOLS\GOODSTUFF')
  21. %      Mac:  path(P,'Tools:GoodStuff')
  22. %
  23. %    See also GETENV, WHAT, CD, DIR.
  24.  
  25. %    Copyright (c) 1984-93 by The MathWorks, Inc.
  26.  
  27. if nargin == 0    % pretty-print
  28.     if nargout == 0
  29.         matlabpath
  30.     else
  31.         p = matlabpath;
  32.     end
  33. elseif nargin == 1
  34.     if ~isstr(a)
  35.         error('Arguments must be strings.')
  36.     end
  37.     matlabpath(a);
  38. elseif nargin == 2
  39.     if ~isstr(a) | ~isstr(b)
  40.         error('Arguments must be strings.')
  41.         end
  42.     pathsep = ':';
  43.     c = computer;
  44.     if strcmp(c(1:2),'PC') |  strcmp(c(1:2),'MA')
  45.         pathsep = ';';
  46.     elseif strcmp(c(1:2),'VA')
  47.         if strcmp(c(1:6),'VAXVMS')
  48.                     pathsep = ',';
  49.             end
  50.     end
  51.     matlabpath([a pathsep b]);
  52. end
  53.