User Tools

Site Tools


matlab:matlab_path

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
matlab:matlab_path [2019/07/10 11:50] – [startup.m] igorkaganmatlab:matlab_path [2022/12/29 07:15] (current) – external edit 127.0.0.1
Line 3: Line 3:
 ==== startup.m ==== ==== startup.m ====
  
-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:+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.
  
-Start up folder (in the MATLAB icon | Properties | Start in ) (e.g. D:\Sources\MATLAB) allows controlling different paths and other settings via startup.m file placed in the folder, e.g.: +If a custom **startup.m** is found on the path, it will be executed: https://www.mathworks.com/help/matlab/ref/startup.html 
 + 
 +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 [[https://www.mathworks.com/help/matlab/ref/userpath.html|userpath]] 
 +(type 'userpath' in the MATLAB command window to figure out yours). 
 + 
 +For examplea minimal **startup.m** for automatically including all GitHub repositories (but excluding not needed internal .git folders) can be just:
  
 <code matlab> <code matlab>
-disp('Welcome to physiology analysis...'); +addpath(genpath_exclude('YOUR_PATH_TO_REPOS','.git'));  
-set_sources_path; % set additional paths dynamicallye.g.  +</code> 
-% addpath(genpath('D:\Sources\MATLAB'));+
  
-cd('F:\Data'); +**Note:** [[https://github.com/igorkagan/matlab_config/blob/master/MATLAB2014/genpath_exclude.m|genpath_exclude.m]] should also be placed in the startup folder. 
-edit+ 
-EditorMacro('Alt-Control-h', @createHeaderComment_dag);+Example startup.m for GitHub repositoriesand Fieldtrip and NeuroElf from DAG server (Y:): 
 + 
 +<code matlab> 
 +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 
 +ft_defaults 
 + 
 +% http://www.fieldtriptoolbox.org/faq/can_i_prevent_external_toolboxes_from_being_added_to_my_matlab_path/ 
 +[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 dbstop if error
 </code> </code>
  
-See https://github.com/igorkagan/matlab_config for example startup.m that allows excluding .git folders from the path.+ 
 +---- 
 + 
 +See also https://github.com/igorkagan/matlab_config for the following example that includes genpath_exclude.m
 + 
 +<code matlab> 
 +disp('Welcome to MATLAB2014'); 
 +set_sources_path; 
 +edit; 
 +EditorMacro('Alt-Control-h', @ig_createHeaderComment_dag); 
 +dbstop if error 
 +</code> 
 + 
 +The function **set_sources_path.m** can be something like the one below, to add all repositories but exclude not needed internal .git folders
 + 
 +<code matlab> 
 +addpath(genpath_exclude('F:\Dropbox\Sources\Repos','.git'));  
 +</code> 
 + 
 + 
 +==== pathdef.m ==== 
 + 
 +When MATLAB gives an "eval..." error on startup, permissions for pathdef.m are screwed up, see: 
 +[[https://www.mathworks.com/matlabcentral/answers/307356-why-do-i-get-an-error-using-eval-undefined-function-workspacefunc-for-arguments-of-type-struct]] 
 + 
matlab/matlab_path.1562759447.txt.gz · Last modified: 2022/12/29 07:15 (external edit)