Why does tab completion not work for p-coded function arguments in MATLAB R2020b?

2 views (last 30 days)
I am using an "arguments" block to define name-value arguments for a MATLAB function, "myRectangle":
function myRectangle(X,Y,options)
arguments
X double
Y double
options.LineStyle (1,1) string = "-"
options.LineWidth (1,1) {mustBeNumeric} = 1
end
% Function code
...
end
I got "myRectangle" from the "arguments" documentation page:
https://www.mathworks.com/help/releases/R2020b/matlab/ref/arguments.html#mw_c78db305-0136-4d4c-b880-f6615c757d8d
I can use tab completion to complete name-value arguments of "myRectangle" when the function is an M-file:
Alt text: The MATLAB command window while I am calling "myRectangle". The tab complete menu shows "LineStyle" and "LineWidth".
However, when "myRectangle" is a P file, MATLAB finds no completions:
Alt text: The MATLAB command window. The command window shows that "myRectangle" is p-coded, and the tab completion menu shows "No completions found."
How can I modify my P file so that I can use tab completion on its arguments?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 9 Jan 2024
Recommended Workaround
As of MATLAB R2022b, MATLAB can tab-complete arguments for p-coded functions. Upgrade your MATLAB to the R2022b release to enable this enhancement for your workflow.
Alternative Workaround
If you do not wish to upgrade, you can use wrapper M-files as an alternative workaround in MATLAB R2020b. For example, say that you p-code the function "myRectangle" that you had earlier. Then you can write a wrapper function, "myRectangleWrapper":
function myRectangleWrapper(X,Y,options)
arguments
X double
Y double
options.LineStyle (1,1) string = "-"
options.LineWidth (1,1) {mustBeNumeric} = 1
end
% Call the p-coded function with the inputs
myRectangle(X, Y, "LineStyle", options.LineStyle, ...
"LineWidth", options.LineWidth);
end
Then, if you enter the text
>> myRectangleWrapper(1, 1, "Line
at the MATLAB command window, you will be able to find "LineWidth" and "LineStyle" when you press tab.

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!