Setting path not working!

11 ビュー (過去 30 日間)
Abhilash
Abhilash 2011 年 9 月 6 日
Hi Guys,
I have my function files in a different directory as -
C:\lab\Abhilash\Analysis Tools
and
C:\lab\Abhilash\Analysis Tools\Third Party
The first folder contains my spike_trains.m function file which calls all other functions within it. In that spike_trains.m file, which is also a function-m file, I give an argument 'directory' which specifies the data directory, wherever it may be and then I do 'addpath(directory)' to add that path.
But I need to have a line which gets the current directory of the function-m files and then adds its path.
When I ask for 'pwd', it only gives me C:\lab\ and not the entire path as I wrote previously.
Could someone please help me out?

採用された回答

Grzegorz Knor
Grzegorz Knor 2011 年 9 月 6 日
If I understand correctly:
mfilename('fullpath')
It returns the full path and name of the file in which the call occurs.
  1 件のコメント
Abhilash
Abhilash 2011 年 9 月 6 日
thanks!

サインインしてコメントする。

その他の回答 (1 件)

Abhilash
Abhilash 2011 年 9 月 6 日
I specified another input argument where the user enters the name of the directory in which his function-m files are and then I do cd(f_dir), but I'd rather have it automated, where the program itself recognises the directory where the m-files are and makes it the current directory.

カテゴリ

Help Center および File ExchangeSearch Path についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by