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

3 views (last 30 days)
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

Accepted Answer

Rik
Rik on 31 May 2018
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 Comment
Micke Malmström
Micke Malmström on 31 May 2018
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

Sign in to comment.

More Answers (0)

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!