checking a matlab function for nested functions
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
how to find programatically if a matlab function m file contains nested function.
fileData = mlintmex('-calls',which(fileName));
fileData = regexp(fileData,'[NS](\d+) (\d+) \d+ (\w+)\n','tokens');
gives the list of function within fileName. My question is how to distinguish local functions from nested functions?
Best regards
7 Kommentare
Image Analyst
am 12 Okt. 2019
You could easily find all function definitions by opening the m-file as a text file, using fgetl() to get a line, then using contains() or startsWith() to see if the line contains a function definition
fid = fopen(mFileName, 'rt');
textLine = fgetl(fid);
while ischar(textLine)
if startsWith(strtrim(textLine), 'function ')
% It's a function definition...
end
textLine = fgetl(fid); % Read next line
end
fclose(fid);
Antworten (1)
Siehe auch
Kategorien
Mehr zu File Compression finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!