Slow Matlab startup if startup.m contains many path additions
4 次查看(过去 30 天)
显示 更早的评论
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
1 个评论
采纳的回答
Richard Crozier
2012-10-4
编辑:Richard Crozier
2012-10-4
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];
addpath(newpath);
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
更多回答(1 个)
K E
2012-7-3
编辑:K E
2012-7-3
3 个评论
Robert Cumming
2012-10-4
By doing it this way every user of your machine will also have all your paths added. Be careful as you may not want this...
Richard Crozier
2012-10-4
No, only users who have access to my startup directory which is only accessible to me, so they have to also be logged in as me. Valid point for others though. I've discovered the real answer to the problem anyway which I have posted below.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!