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