Friday, January 16, 2009

MATLAB: Set working path at startup

Many times when MATLAB is started there is a certain program that you want to work on. In order to work on this program, the current directory or path of that program must be changed or set.  This little script here will prompt the user for the module to work on and then add that directory to the path listing. When MATLAB is terminated, that path will not be saved.
% startup.m

% Set Production Directory
prod='~/MATLAB/Production/';

% Prompt user for module name
module=input('What module do you want to work on? ','s');

% If module is set, add to top of path. Otherwise don't add
if ~isempty(module)
path([prod,module],path);
end
Place the startup.m in your MATLAB work directory.

1 comment:

  1. This comment has been removed by the author.

    ReplyDelete

Sociable