MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1

switch V{n}
case 'Name1'
NV1 = V{n+1};
case 'Name2'
NV2 = V{n+1}
otherwise
error('Error.')
end
end
end
end


In the same folder as myFunc, create the following function signature description in a file
called functionSignatures.json. The input names do not match the names in the
body of myFunc, but are consistent with the help text.


{
"_schemaVersion": "1.0.0",
"myFunc":
{
"inputs":
[
{"name":"in1", "kind":"required", "type":["numeric"], "purpose":"ID of item"},
{"name":"in2", "kind":"required", "type":["numeric"], "purpose":"# Items"},
{"name":"in3", "kind":"ordered", "type":["numeric"], "purpose":"Input Value"},
{"name":"Name1", "kind":"namevalue", "type":["logical","scalar"],"purpose":"Option"},
{"name":"Name2", "kind":"namevalue", "type":["char", "choices={'Default','Choice1','Choice2'}"]}
]
}
}


MATLAB uses this function signature description to inform code suggestions and
completion.


To experiment with code suggestions, start to call the function from a live script and
observe the suggestions. For example, the names and purposes from the JSON file appear.
MATLAB indicates when arguments are optional and if there are multiple suggestions
available (such as the third positional argument or a name-value pair). Name-value pairs
options are listed.


When adding a name-value pair argument to the function call, MATLAB presents the
choices from the JSON file. Since 'Name1' is defined as a logical scalar, MATLAB


Customize Code Suggestions and Completions
Free download pdf