Comment my function in order to get a decent title in the documentation

171 views (last 30 days)
Hello everyone,
I am in the process of figuring out how to comment adequately my function so that its html published version is easy to read for everyone. By that I mean that I would appreciate if it had a nice bold orange title, with a description underneath it and then the table of content for each section. The code as is generated by Matlab when creating a new function is:
function [curve] = historical_curve(index_name,id,date,starting_bin,nb_cont_bins,bin_length,method)
%UNTITLED3 Summary of this function goes here
% Detailed explanation goes here
When publishing without executing the code for performance purposes, it yields nothing . I tried the example in the documentation, but apparently I can only manage to get it working for this script, not my function.
I have tried adding up the "%% " before the title, it does not work.
Any ideas ? Thanks for reading this :)

Accepted Answer

Brendan Hamm
Brendan Hamm on 28 Jul 2015
When publishing a function (just like with a script) the file is run, however with a function you require inputs. If you select "edit Publishing options" from the Publish drop down menu item you will have the opportunity to provide these. See attached screen shot.
My function requires 2 inputs, so I create these in the "MATLAB expressions" section and call my function. You will note that your function will be called on this line by default, but without input arguments.
  5 Comments
Brendan Hamm
Brendan Hamm on 28 Jul 2015
Ok. One thing you way want to consider is having all of the publication text before the function declaration. Now you will not have this problem. Often times you would not want to include the actual code in the documentation, so I have turned this off as well.
Vincent
Vincent on 28 Jul 2015
I tested out your solution and it works perfectly fine. I think I'l stick to that then. It's pretty weird though; once I get more than two section title above the function definition, I don't have the above mentioned problem.
Anyway, thanks a lot for helping me out !

Sign in to comment.

More Answers (0)

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!