forked from cerr/CERR
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddToPath.m
More file actions
27 lines (25 loc) · 676 Bytes
/
Copy pathaddToPath.m
File metadata and controls
27 lines (25 loc) · 676 Bytes
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
function success = addToPath(cerrDir)
% function success = addCerrToPath(cerrDir)
%
% This function adds subfolders in cerrDir to MATLAB/OCTAVE path excluding
% the .git folders.
%
% Example:
% cerrDir = 'C:\Path\to\CERR\';
% addToPath(cerrDir)
%
% APA, 7/29/2021
pathStr = genpath(cerrDir);
if ispc
indSemiColonV = strfind(pathStr,';');
else
indSemiColonV = strfind(pathStr,':');
end
indGitV = strfind(pathStr,'.git');
minIndV = arrayfun(@(x) max(indSemiColonV(indSemiColonV<x)),indGitV);
maxIndV = arrayfun(@(x) min(indSemiColonV(indSemiColonV>x)),indGitV);
for i = length(minIndV):-1:1
pathStr(minIndV(i):maxIndV(i)-1) = [];
end
addpath(pathStr)
success = 1;