MATLAB Answers

0

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

Alessandro さんによって質問されました 2014 年 10 月 13 日
最新アクティビティ Alessandro さんによって コメントされました 2014 年 10 月 13 日
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.

  0 件のコメント

サインイン to comment.

製品

1 件の回答

回答者: Guillaume
2014 年 10 月 13 日
編集済み: Guillaume
2014 年 10 月 13 日
 採用された回答

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.

  2 件のコメント

Guillaume
2014 年 10 月 13 日
It works just as well for classes, class methods and class properties:
classdef myclass
%MYCLASS a description of my class
%This is a class for ...
properties
someprop; %someprop doc
end
methods
function out = somefunc(myclass)
%SOMEFUNC does something
%more information about SOMEFUNC
end
end
end
>>help myclass
>>help myclass.someprop
>>help myclass.somefunc
Alessandro 2014 年 10 月 13 日
You are right ! thanks

サインイン to comment.



Translated by