Adding functions permanently to matlab
153 次查看(过去 30 天)
显示 更早的评论
I have many self developed functions in a folder called Finance (C:\Documents\MATLAB\Finance). I sthere a way to add these functions permanently to my matlab path so whenever i use a script this script would call them automatically?
0 个评论
采纳的回答
Matt Fig
2011-7-2
Yes, look under File>Set Path. Add the directory Finance to the path. This should persist between sessions.
1 个评论
更多回答(2 个)
the cyclist
2011-7-2
Yes. Use the path() or addpath() command in a file called startup.m, in the top-level MATLAB directory. For example, where is how I added a utilities directory (on a Mac):
path(path,genpath('/Users/thecyclist/Documents/MATLAB/utilities'));
That file is run at MATLAB start.
3 个评论
John D'Errico
2020-5-21
This is a completely different question. Please don't resurrect an old question to ask a new one.
But do NOT put functions in the matlabroot directories. The toolbox directories are cached on startup, so any changes you make to your personal functions will not be seen.
AMM
2020-5-21
John-
I asked here because I thought my query was directly relevant to the OP's question (modulo "how" vs. "where"). My apologies. I'll re-post this as a new question.
Thanks also for the info about caching at startup. I can easily imagine this would result in confusing/unexpected behavior if I were to edit any of those functions during a session, then fail to quit/restart. Cheers.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Search Path 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!