User Tools

Site Tools


Table of Contents



When MATLAB starts, it will look for a pathdef.m file in its startup directory. It should not be edited - leave the default MATLAB path containing only MATLAB native toolboxes. The rest should be configured dynamically, as explained below.

If a custom startup.m is found on the path, it will be executed:

There are two ways to configure place the startup.m on the path:

1. Custom startup folder set via MATLAB icon: (right click on the MATLAB icon | Properties | Start in ) (e.g. F:\Dropbox\Sources\Repos\matlab_config\MATLAB2014) allows controlling different paths and other settings via startup.m file placed in this folder.

2. Place custom startup.m to your userpath (type 'userpath' in the MATLAB command window to figure out yours).

For example, a minimal startup.m for automatically including all GitHub repositories (but excluding not needed internal .git folders) can be just:


Note: genpath_exclude.m should also be placed in the startup folder.

Example startup.m for GitHub repositoriesand Fieldtrip and NeuroElf from DAG server (Y:):

disp('Welcome to YOUR MATLAB VERSION, e.g. MATLAB2014a');
addpath(genpath_exclude('YOUR_PATH_TO_REPOS','.git')); %<--- !!! change 'YOUR_PATH_TO_REPOS'
addpath('Y:\Sources\fieldtrip-20200604'); % or other path to fieldtrip
[ftver, ftpath] = ft_version;
rmpath(fullfile(ftpath, 'external', 'signal'))
rmpath(fullfile(ftpath, 'external', 'stats'))
rmpath(fullfile(ftpath, 'external', 'images'))
addpath('Y:\Sources\NeuroElf_v11_7521'); addpath('Y:\Sources\NeuroElf_v11_7521\add_dag_ne_pipeline');
dbstop if error

See also for the following example that includes genpath_exclude.m:

disp('Welcome to MATLAB2014');
EditorMacro('Alt-Control-h', @ig_createHeaderComment_dag);
dbstop if error

The function set_sources_path.m can be something like the one below, to add all repositories but exclude not needed internal .git folders:



When MATLAB gives an “eval…” error on startup, permissions for pathdef.m are screwed up, see:

matlab/matlab_path.txt · Last modified: 2022/12/29 07:15 by