Skip to content

Instantly share code, notes, and snippets.

@MarcinKonowalczyk
Last active June 30, 2020 18:10
Show Gist options
  • Save MarcinKonowalczyk/bc4bf8b9daeea4f60261ae2750557a98 to your computer and use it in GitHub Desktop.
Save MarcinKonowalczyk/bc4bf8b9daeea4f60261ae2750557a98 to your computer and use it in GitHub Desktop.
[Matlab] Name of Caller
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