how to create function without having to use all the inputs in the script
Mostrar comentarios más antiguos
i have a function with many inputs how can i write this function so i would not have to fill all the inputs? for example now i have this function
T=Tavg('none',12,[],[])
to avoid using the last 2 inputs i must set them to empty array in the script
Respuesta aceptada
Más respuestas (1)
James Tursa
el 24 de Oct. de 2014
Use nargin in your function to determine how many inputs are actually being passed in. E.g.
function T = Tavg(a,b,c,d)
if( nargin == 2 )
c = something; % c wasn't passed in
d = something; % d wasn't passed in
end
etc.
Categorías
Más información sobre Call MATLAB from C++ 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!