Slow Matlab startup if startup.m contains many path additions
10 views (last 30 days)
I am asking/answering my own question, hoping it will help someone with the same issue:
If Matlab takes 3+ minutes to start up, how can I speed it up? My startup.m file contains many calls to add directories to my path, and those directories reside on a network drive. For example:
path(path, 'S:\top_code_directory\some_subdirectory') ; % Many calls like this
path(path, genpath('S:\project_directories')) ; % Many subdirectories are added
Richard Crozier on 4 Oct 2012
Edited: Richard Crozier on 4 Oct 2012
build the path yourself and do a single call to addpath, addpath expects a single string containing path names separated by semicolons. So try something like the following:
apath = 'S:\top_code_directory\some_subdirectory;'
newpath = [genpath('S:\project_directories'), apath];
Obviously your construction of the path string to add will be more complex. Just remember that genpath already produces a string ending in a semicolon so you don't need to add one to the string produced by it.
You will find this much faster, as the bottleneck is the function path.m