How to allow same function name to be used various ways?
Mostrar comentarios más antiguos
I understand how to achieve this interms of the outputs and code exercuted but how do you allow the pop out box display all different possible inputs such as the plot example I've attached

Respuestas (3)
Ameer Hamza
el 13 de Abr. de 2020
1 voto
In mac, the suggestion lists pop up by simultaneously pressing Control and 1. I guess the same will work on windows.
3 comentarios
James Ashcroft
el 13 de Abr. de 2020
Ameer Hamza
el 13 de Abr. de 2020
Ok. I get it now. If you want such suggestion pop up for your own function, then you need to create the JSON file as described here: https://www.mathworks.com/help/matlab/matlab_prog/customize-code-suggestions-and-completions.html
James Ashcroft
el 13 de Abr. de 2020
Image Analyst
el 13 de Abr. de 2020
You can use varargin and then check the inputs
function output = MyFunction(varargin)
if nargin == 1
value1 = vargin{1}
value2 = 20; % Some default
else if nargin == 2
value1 = vargin{1}
value2 = vargin{2}
end
I think that's the easiest, and what I do. But the official way is to use the inputparser: https://www.mathworks.com/help/matlab/input-and-output-arguments.html?s_tid=CRUX_lftnav
Steven Lord
el 13 de Abr. de 2020
0 votos
You can customize completions for the functions you've written if you're using release R2018a or later.
1 comentario
James Ashcroft
el 13 de Abr. de 2020
Categorías
Más información sobre Create Custom UI Components en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



