MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1
arguments. For these function signatures, define tuples and set the repeating property
to true.

mutuallyExclusiveGroup – Definition of set of exclusive arguments

Definition of a set of sets of arguments that cannot be used together, specified as a list of
argument objects. This property is used to provide information about functions with
multiple function signatures. However, typically it is easier to define multiple function
signatures using multiple function objects. For more information, see “Multiple
Signatures” on page 30-24.

Create Function Signature File


This example describes how to create custom code suggestions and completions for a
function.

Create a function whose signature you will describe in a JSON file in later steps. The
following function accepts:


  • Two required arguments

  • One optional positional argument via varargin

  • Two optional name-value pair arguments via varargin


myFunc is presented to demonstrate code suggestions and does not include argument
checking.
% myFunc Example function
% This function is called with any of these syntaxes:
%
% myFunc(in1, in2) accepts 2 required arguments.
% myFunc(in1, in2, in3) also accepts an optional 3rd argument.
% myFunc(___, NAME, VALUE) accepts one or more of the following name-value pair
% arguments. This syntax can be used in any of the previous syntaxes.
% * 'NAME1' with logical value
% * 'NAME2' with 'Default', 'Choice1', or 'Choice2'
function myFunc(reqA,reqB,varargin)
% Initialize default values
NV1 = true;
NV2 = 'Default';
posA = [];
if nargin > 3
if rem(nargin,2)
posA = varargin{1};
V = varargin(2:end);
else
V = varargin;
end
for n = 1:2:size(V,2)

30 Custom Help and Documentation

Free download pdf