MATLAB: How to determine if a function foo in file foo.m has an empty documentation string in r2017b (or later)

distance_learningdocumentation stringmatlab onlinematlab_onliner2017b

On previous versions, isempty(help('foo')) worked, but now it seems help('foo') returns a non-empty, non-constant default.

Best Answer

function tf = isemptyhelp(topic)
%returns true if topic is not a function with a documentation string
%including returning true for anything that is not a function or function handle
%examples of first line of help output in R2017b:
% Input is a value of type double.
% f is a variable of type function_handle.
% f is a function.
helpstr = help(topic);
tokens = regexp(helpstr, '\s+', 'split');
tf = isempty(tokens) || (length(tokens) >= 4 && strcmp(tokens{2}, 'is') && strcmp(tokens{3}, 'a');
end