-
Notifications
You must be signed in to change notification settings - Fork 0
/
addsandbox.m
43 lines (36 loc) · 1.13 KB
/
addsandbox.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
function addsandbox()
%addsandbox Install sandbox
%
% See also: rmsandbox
%
% Copyright 2016 The MathWorks, Inc.
thisFolder = fileparts( mfilename( 'fullpath' ) );
% TODO: Add folders to add to MATLAB path
tbxFolder = fullfile( thisFolder, 'tbx' );
fl = dir( tbxFolder );
fl = fl( [fl.isdir] & ~strcmp( {fl.name}, '.' ) & ~strcmp( {fl.name}, '..' ) );
foldersToAdd = [
tbxFolder;
strcat( [tbxFolder filesep], {fl.name}' )
];
% Capture path
oldPathList = path();
% Add toolbox directory to saved path
userPathList = userpath();
if isempty( userPathList )
userPathCell = cell( [0 1] );
else
userPathCell = textscan( userPathList, '%s', 'Delimiter', ';' );
userPathCell = userPathCell{:};
end
savedPathList = pathdef();
savedPathCell = textscan( savedPathList, '%s', 'Delimiter', ';' );
savedPathCell = savedPathCell{:};
savedPathCell = setdiff( savedPathCell, userPathCell, 'stable' );
savedPathCell = [foldersToAdd; savedPathCell];
path( sprintf( '%s;', userPathCell{:}, savedPathCell{:} ) )
savepath()
% Restore path plus toolbox directory
path( oldPathList )
addpath( sprintf( '%s;', foldersToAdd{:} ) )
end % addsandbox