How can my code know if it iss called from the base or from some other function?

조회 수: 2 (최근 30일)
I want my "figure formatting function" to copy the current figure if it is called from "base"-workspace but not if it is called from another function or script. How can I add this functionally to my "figure formatting function"?
thanks

채택된 답변

Rik
Rik 2018년 5월 31일
With the dbstack function you can get the calling functions. Be aware that some releases have a function that is called to run a section, while older releases just return an empty struct.
  댓글 수: 1
Micke Malmström
Micke Malmström 2018년 5월 31일
Thanks!
ST = dbstack;
if length(ST)==1 % then it is in base otherwise the stack is "longer"
print(h,'-dmeta') % this puts a copy of the figure in the clipboard
disp(['Figure copied']);
end

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by