Last active
June 30, 2020 18:10
-
-
Save MarcinKonowalczyk/bc4bf8b9daeea4f60261ae2750557a98 to your computer and use it in GitHub Desktop.
[Matlab] Name of Caller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function name = noc() | |
%% name = noc() | |
% Name of caller. Allows the funciton to get the name of the calling | |
% funciton. Returns 'base' if there is no caller, and 'command line' if | |
% caled from the command window. | |
stack = dbstack; | |
if numel(stack) == 1 % Only this function in stack | |
name = 'command line'; | |
elseif numel(dbstack) == 2 % Called by only one other function | |
name = 'base'; | |
else % Called by a larger stack | |
name = stack(3).name; | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment