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?

 채택된 답변

Matt Fig
Matt Fig 2011년 7월 2일

7 개 추천

Yes, look under File>Set Path. Add the directory Finance to the path. This should persist between sessions.

댓글 수: 1

Nagabhushan SN
Nagabhushan SN 2018년 8월 31일
In MatLab R2018a, look under Home > ENVIRONMENT > Set Path

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Paulo Silva
Paulo Silva 2011년 7월 2일

4 개 추천

use pathtool to select that folder and save
the cyclist
the cyclist 2011년 7월 2일

1 개 추천

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

AMM
AMM 2020년 5월 21일
편집: AMM 2020년 5월 21일
(Sorry to resurrect a very old thread...)
I know about path, pathtool, and the GUI approach suggested above to make functions available from the Command Prompt, and I realize any of those would work for functions located pretty much anywhere on the host.
Just curious: is there a conventional / standard / "best practices" location for parking such self-developed functions, as per the OP's question? Initially I thought about $MATLABROOT/toolbox/local, but that seems to contain exclusively Mathworks-provided scripts and text files.
John D'Errico
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
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.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Search Path에 대해 자세히 알아보기

태그

질문:

2011년 7월 2일

댓글:

AMM
2020년 5월 21일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by