Code covered by the BSD License  

Highlights from
pushd

  • popd POPD Pops you back up in the PUSHD stack
  • pushd(varargin) PUSHD Changes MATLAB working directory to the one specified, or to the folder containing the specified file
  • View all files
from pushd by Peter (PB) Bodin
MATLAB version of pushd & popd, both available in UNIX/Linux and DOS. Adds some Matlab specific feat

popd
function popd
%POPD Pops you back up in the PUSHD stack
%
%   See also pushd, cd, pwd

% Author: Peter Bodin (PB)
% pbodin@kth.se
% Created: Jul 2005
% Updated 2005-08-09
% Changes:
% Added stack functionality


% <BEGIN LICENCE>
% This program is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation; either version 2 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program; if not, write to the Free Software
% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
% <END LICENCE>

if isempty(getpref('pushd','pushed'))
    %warning('You have reached the end of the PUSHD stack, I have nowhere to pop!');
elseif ~isempty(getpref('pushd','pushed')) & strcmp(getpref('pushd','pushed'),'*$*')
    setpref('pushd','pushed',[]);
    popd
elseif  ispref('pushd','pushed')
    [wheretopop,remainingstack]=(strtok(fliplr(getpref('pushd','pushed')),'*$*'));
    wheretopop=fliplr(wheretopop);
    remainingstack=fliplr(remainingstack);
    setpref('pushd','pushed',remainingstack);
    try
    cd(wheretopop);
    catch
            warning(lasterr)
    end
else
    warning('You havent used PUSHD, I have nowhere to pop!');
end

Contact us at files@mathworks.com