Locate path of .m file that creates the specified object
5 ビュー (過去 30 日間)
古いコメントを表示
Hello,
Assume that I have the custom classdef defined. While calling the class constructor, I want to add a propery that contains the full path to the script or function that called the classdef .m file. I do not want to add this manually every time the object of this class is being created. I tried to use mfilename (gives the path to classdef file) and dbstack, but I want to have only one variable, that unambiguously says where the certain object has been created within all project scritps.
Thanks for help.
5 件のコメント
Steven Lord
2023 年 2 月 5 日
dbstack also wouldn't work if the object was created at the Command Window prompt.
>> d = dbstack
d =
0×1 empty struct array with fields:
file
name
line
If you tried running dbstack in MATLAB Answers you'll actually get information about the infrastructure used to run the code.
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Class File Organization についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!