-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinitDemo.m
More file actions
37 lines (31 loc) · 1.12 KB
/
Copy pathinitDemo.m
File metadata and controls
37 lines (31 loc) · 1.12 KB
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
function initDemo()
% initDemo - Single-line initialization for demo scripts
% The function automatically:
% - Adds src to MATLAB path
% - Adds the controllers package
% - Adds the appropriate demos folder (auto-detected)
% Get src root
src_root = fileparts(mfilename('fullpath'));
% Add src to path first
addpath(src_root, '-begin');
% Auto-detect controller type from calling script location
stack = dbstack('-completenames');
controller_type = '';
if numel(stack) > 1
caller_file = stack(2).file;
if contains(caller_file, [filesep 'dmc' filesep])
controller_type = 'dmc';
elseif contains(caller_file, [filesep 'epfc' filesep])
controller_type = 'epfc';
end
end
% Run bootstrap to handle additional setup
run(fullfile(src_root, 'bootstrap.m'));
% Add the appropriate demos folder
if ~isempty(controller_type)
demos_path = fullfile(src_root, 'utils', controller_type);
if exist(demos_path, 'dir')
addpath(demos_path, '-begin');
end
end
end