Custom functionSignatures.json stopped working on upgrade from R2019b to R2021b

5 Ansichten (letzte 30 Tage)
I created a plot generator function in R2019a. It takes in a table and up to 4 column names to group and plot the data. I added a functionSignatures.json file next to it which was really handy to autocomplete the possible column names. When I upgraded to R2021b the autocomplete stopped working. If I re-open R2019b (still installed side-by-side with 2021b) the exact same inputs still work as they used to, but in 2021b it just shows "No suggestions found".
I searched the release notes for references to json between these two versions and didn't see anything stick out. https://www.mathworks.com/help/matlab/release-notes.html?rntext=json&startrelease=R2019b&endrelease=R2021b&groupby=release&sortby=descending&searchHighlight=json
I was able to re-create this behavior with the minimal example below:
functionSignatures.json
{
"MyPlot":
{
"inputs": [
{"name":"tbl", "kind":"required", "type":"table"},
{"name":"xvar", "kind":"positional", "type":["choices=matlab.internal.tabular.functionsignatures.keyChoices(tbl)"]},
{"name":"yvar", "kind":"positional", "type":["choices=matlab.internal.tabular.functionsignatures.keyChoices(tbl)"]},
{"name":"extra1", "kind":"positional", "type":["choices=matlab.internal.tabular.functionsignatures.keyChoices(tbl)"]},
{"name":"extra2", "kind":"positional", "type":["choices=matlab.internal.tabular.functionsignatures.keyChoices(tbl)"]}
],
"outputs": [
{"name":"out"}
]
}
}
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.
MyPlot.m
function MyPlot(tbl, xvar, yvar, extra1, extra2)
plot(tbl.(xvar), tbl.(yvar));
end
Add those two files next to each other in some folder and go to that folder in R2019b.
Create a dummy table
t = table([1:10]', rand(10,1), 'VariableNames', {'Idx','RandNum'})
and try to use MyPlot
MyPlot(t, '
and you will see autocomplete options
Repeat this in 2021b and you will see "No completions found"
Please advise if I need to update something for this to work in 2021b. My plotter function still works, I just wish I got to use the autocomplete I'm used to having.

Akzeptierte Antwort

Chris Dean
Chris Dean am 18 Nov. 2022
The issue is the
choices=matlab.internal.tabular.functionsignatures.keyChoices
needs to be
choices=matlab.internal.tabular.functionSignatures.keyChoices
in R2021b+ (possibly any version after 2019b)
The lower case "s" in "functionsignatures.keyChoices" needs to be capital "S" in functionSignatures.keyChoices
  1 Kommentar
Steven Lord
Steven Lord am 18 Nov. 2022
As stated in the "Internal Packages" section on this documentation page:
"MathWorks® reserves the use of packages named internal for utility functions used by internal MATLAB code. Functions that belong to an internal package are intended for MathWorks use only. Using functions or classes that belong to an internal package is discouraged. These functions and classes are not guaranteed to work in a consistent manner from one release to the next. Any of these functions and classes might be removed from the MATLAB software in any subsequent release without notice and without documentation in the product release notes."
If this functionality is useful for you, please submit an enhancement request asking for this functionality to be added as a documented function. To submit the enhancement request to Technical Support directly please use the Contact Support link under the Get Support heading at the end of this page.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by