, , getcallinfo:
g = getcallinfo('filename.m');
f = g(1).calls.fcnCalls.names;
, g - . g(1) , f - , . f (, g(1).calls.fcnCalls.lines). , which:
cellfun(@(x) which(x), unique(f))
unique . , , , which, , .
perms.m :
>> g = getcallinfo('perms.m')
>> g(1)
ans =
struct with fields:
type: [1×1 internal.matlab.codetools.reports.matlabType.Function]
name: 'perms'
fullname: 'perms'
functionPrefix: 'perms>'
calls: [1×1 struct]
firstline: 1
lastline: 37
linemask: [61×1 logical]
>> g(2)
ans =
struct with fields:
type: 'subfunction'
name: 'permsr'
fullname: 'perms>permsr'
functionPrefix: 'perms>permsr'
calls: [1×1 struct]
firstline: 40
lastline: 61
linemask: [61×1 logical]
>> f = g(1).calls.fcnCalls.names
f =
1×8 cell array
'cast' 'computer' 'error' 'factorial' 'isequal' 'length' 'message' 'numel'
>> cellfun(@(x) which(x), unique(f))
built-in (C:\Program Files\MATLAB\R2016b\toolbox\matlab\datatypes\cast)
built-in (C:\Program Files\MATLAB\R2016b\toolbox\matlab\general\computer)
built-in (C:\Program Files\MATLAB\R2016b\toolbox\matlab\lang\error)
C:\Program Files\MATLAB\R2016b\toolbox\matlab\specfun\factorial.m
built-in (C:\Program Files\MATLAB\R2016b\toolbox\matlab\elmat\isequal)
built-in (C:\Program Files\MATLAB\R2016b\toolbox\matlab\elmat\length)
message is a built-in method % message constructor
built-in (C:\Program Files\MATLAB\R2016b\toolbox\matlab\elmat\numel)