How to add multiple suggestions to the automatic pop-up help boxes when typing a function?

I have some functions that can accept variable amounts of inputs and I want to better document them by adding appropriate suggestions to the box that pops up when you begin typing the function name, like this:
find(.png
Most built-in Matlab functions display help boxes like this but when I write a function from scratch, it either displays the inputs I specifically have listed, or it shows (...) if the function accepts "varargin", like so:
plot_Earth_km(.png
Those functions of course already handle the inputs properly, but I want to display the various acceptable ways of calling the function in the displayed suggestions here. Is there a way to customize this feature?

4 Comments

Could you share the plot_Earth_km() function or at least the part that declares the function at the top?
Hi Adam,
Sorry I missed your response so long ago. Here is how the function is called:
function [ax,Gh] = plot_Earth_km(varargin)
% Plots the Earth with a textured map to scale in kilometers.
%
% plot_Earth_km(eq_pts) plots Earth with eq_pts number of points around the
% equator
%
% plot_Earth_km(eq_pts,[...]) allows several display options via name-value
% pairs of inputs.
%
% EXAMPLES:
% [ax,gh] = plot_Earth_km(eq_pts,'GMST',GMST);
% [ax,gh] = plot_Earth_km(eq_pts,'GMST',GMST,'Style','Night');
% [ax,gh] = plot_Earth_km(eq_pts,'JD',JD,'Style','Sunlit');
The entire function is very long, but the examples part of the help section shows some of the ways I would like suggestions to appear in the suggestion box. Obviously it currently only shows "varargin" as being an argument to the function. varargin is (are) parsed with an inputParser.
% Create parser for the inputs:
p = inputParser;
addRequired(p,'eq_pts',validPosInt)
addParameter(p,'GMST',default_GMST0,validScalar);
addParameter(p,'JD',default_JD0,validScalar);
addParameter(p,'Style','Day',validStyles);
[...]
% Parse the inputs:
parse(p,varargin{:})
% Extract the resulting parsed (or default) values from the given inputs:
eq_pts = p.Results.eq_pts;
GMST0 = p.Results.GMST;
JD0 = p.Results.JD;
Style = p.Results.Style;
[...]
The function does different things depending on which name-value pairs are passed. Of course if a user needs to know how to use it, they can view the help documentation, but I'd like to know how to change the suggestions if possible.
I know what you're talking about. I've never done this myself but here's a lead.
and
A quicker alternative would be to make useful 'help' notes at the top of your code and cover all of the possible inputs. It looks like you're already doing that.
Ah, thank you! Unfortunately I have 2015b, so it looks like that functionality is not supported in my version. Good find though.

Sign in to comment.

Answers (1)

Starting with MATLAB R2018a, you can personalize code suggestions and completions for your functions by following the Customize Code Suggestions and Completions documentation.

Categories

Find more on Argument Definitions in Help Center and File Exchange

Asked:

on 13 Dec 2018

Answered:

on 19 Aug 2025

Community Treasure Hunt

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

Start Hunting!