I create a function
function y = getValue(modelName, param, option)
open_system(modelName);
runModel(option);
y = getActiveFun(param);
end
I would like when calling this function to have the choice to pass or not argument option
from some other files I call the function with all arguments and sometimes I would like to call it without passing option argument ?
I would like to call : getValue(modelName, param) from other files
How could I do that ?
The simplest way to do this is to use the
narginvariable:narginis just the number of input arguments that were actually submitted. Thus,nargin == 3indicates that the option parameter has been set,nargin < 3that it has not been set.Thus, you could now always call your function like
or with all parameters