Daniel@0: function addtosystempath(p) Daniel@0: % Add p to the system path. If p is already on the path, this does nothing. Daniel@0: % Note, this change only persists for the duration of the Matlab session. Daniel@0: % Do not include path delimiters like ; or : . Daniel@0: % Example: Daniel@0: % addtosystempath('C:\Users\matt\bin'); Daniel@0: Daniel@0: if isempty(getenv('PATH')) || all(cellfun(@(c)isempty(c),strfind(tokenize(getenv('PATH'),pathsep()),p))); Daniel@0: setenv('PATH', [p, pathsep(), getenv('PATH'),]); Daniel@0: end Daniel@0: Daniel@0: end