When overloading a builtin function: can I copy the original signature to allow auto-complete?
1 次查看(过去 30 天)
显示 更早的评论
Say I define my own implementation for the plot function:
function varargout = plot(varargin)
% do my own stuff
% ...
% call the builtin function:
[varargout{1:nargout}] = builtin('plot', varargin{:});
end
It all works fine, except that the new function does not auto-complete.
Can I copy the signature of the built-in function to my new function to allow auto-complete?
0 个评论
回答(1 个)
Ramtej
2023-9-5
Hi royk,
I assume "new function does not auto complete" means that MATLAB does not auto complete the name of your function.
The auto completion does not work because your new function definition file is not in the MATLAB path.
Add the folder of new function to the MATLAB path, then auto complete should work.
You can refer to the Function Precedence Order when you are calling the overloaded function.
Link to documentation: https://in.mathworks.com/help/matlab/matlab_prog/function-precedence-order.html
Hope this resolves your query!
1 个评论
Benjamin Penazek
2024-10-1
I assume rather that royk means there is no autocomplete for plot-related inputs like 'LineWidth' and other positional and name-value arguments. It's nice to hit TAB and have a list of arguments to supply, like line colors and markers. Otherwise we're at the mercy of our memory with how things are spelled and capitalized.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Environment and Settings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!