How can I define multiple named inputs for a function
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
This is exactly what I mean!!
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/155654/image.png)
The default function eye() admits multiple variables, something like varargin.
Other property is that it displays all the different possibilities!
If someone can help me, I'll be very grateful!
Thank you very much
Iagoba
0 comentarios
Respuestas (1)
Amit
el 27 de En. de 2014
This is a nice info regarding what you're asking: http://www.mathworks.com/help/matlab/matlab_prog/support-variable-number-of-inputs.html
3 comentarios
Amit
el 27 de En. de 2014
If you want really a fancy tab completion, see this: http://undocumentedmatlab.com/blog/setting-desktop-tab-completions/
for a relatively simple one:
function a = myfunc(var1,var2,var3)
if nargin < 1
var1 = defaultvalueforvar1;
end
if nargin < 2
var2 = defaultvalueforvar1;
end
if nargin < 3
var3 = defaultvalueforvar1;
end
end
This will show tab completion for all 3 variable, however only 1 or less than 1 variable needed.
Ver también
Categorías
Más información sobre Matrix Indexing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!