フィルターのクリア

Is there any way to automatically collect an input argument?

1 回表示 (過去 30 日間)
Graham House
Graham House 2014 年 4 月 1 日
コメント済み: Graham House 2014 年 4 月 1 日
Say you have a function that you can call by saying:
Example1(Location,a,b,c);
Now the 'Location' in question is always the location of the script which is running the function so would always be defined as:
Location = mfilename('fullpath')
Is there any way of getting a function to automatically acquire the input argument 'Location'? That way I could avoid anyone who might use my function from entering the wrong location out of confusion (the script in question deals with a number of locations).
Thanks
Graham

採用された回答

Image Analyst
Image Analyst 2014 年 4 月 1 日
You need to call dbstack with the 'completenames' option:
Example. Script "test2.m" calls function test1() (contained in the same test2.m script or in it's own m-file). See dbstack give the full pathnames of the routines that are called:
function test2
test1
function test1()
dbstack('-completenames')
  1 件のコメント
Graham House
Graham House 2014 年 4 月 1 日
Thanks very much works perfectly.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by