필터 지우기
필터 지우기

Locate path of .m file that creates the specified object

조회 수: 5 (최근 30일)
Grzegorz Diaczek
Grzegorz Diaczek 2023년 2월 4일
댓글: Grzegorz Diaczek 2023년 2월 5일
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
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.
Grzegorz Diaczek
Grzegorz Diaczek 2023년 2월 5일
I checked it one more time, your're right, I see the path to the function that called the classdef file, looks like I omitted some stacks before. Thanks for help.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Software Development Tools에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by