Function name. filename
% thisFunc name
% thisFunc line
% thisFunc file
function str = thisFunc(field)
%THISFUNC infor of currently running function
% carry with some debug info
% st(1): funcName st(2): currently running function
st = dbstack;
if length(st) > 1, n = 2; else n = 1; end
str = st(n).(field);
% thisFunc().file
% classdef thisFunc
% properties
% file, name, line
% end
%
% methods
% function obj = thisFunc()
% st = dbstack;
% if length(st) > 1, n = 2; else n = 1; end
%
% s = st(n);
% obj.file = s.file;
% obj.name = s.name;
% obj.line = s.line;
% end
% end
% end
function out = callerFunc(field)
%CALLERFUNC infor of current function's caller function
% carry with some debug info
% st(1): funcName st(2): currently running function
st = dbstack;
L = length(st);
if L < 3
out = [];
func = callerFunc;
warning('callerFunc of ''%s'' not exist, see file ''%s'' line %d', ...
func.name, func.file, func.line);
else
if nargin == 0
out = st(3);
else
out = st(3).(field);
end
end