display in Matlab comments of functions or methods of classes in the console

8 views (last 30 days)
Hello is it possible in Matlab to show from the console the comments of a function ? For instance if I have a function like this:
%this is a function
function result = afunction()
blah = 2;
result = 21;
I would like to display the first lines of comments. In the console I would like to have something like this:
>> whatisdoing afunction
this is a function
Or even better if I could do this from matlab to display the comments of member methods from classes. I know there is the help command but it doesn t show the comments of functions.

Accepted Answer

Guillaume on 13 Oct 2014
Edited: Guillaume on 13 Oct 2014
help is actually the function you want. It does show the help (comments) of member function as well, as long as those comments are in the right location.
Put your comments after the
function result = afunction()
line, and help will show them.
For more details, see this help topic.

Sign in to comment.

More Answers (0)


Find more on Argument Definitions in Help Center and File Exchange


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!