Skip to content
Snippets Groups Projects
Commit 07447f7a authored by Federico Felici's avatar Federico Felici
Browse files

Allow initialization functions with no input arguments

parent 5a008dd5
No related branches found
No related tags found
No related merge requests found
...@@ -253,7 +253,13 @@ classdef SCDclass_algo ...@@ -253,7 +253,13 @@ classdef SCDclass_algo
initcmd=sprintf('%s(obj);', initfunction); initcmd=sprintf('%s(obj);', initfunction);
value = eval(initcmd); value = eval(initcmd);
elseif isa(initfunction,'function_handle') elseif isa(initfunction,'function_handle')
value = initfunction(obj); % call function handle directly if nargin(initfunction)==1
value = initfunction(obj); % function has an input argument
elseif nargin(initfunction)==0
value = initfunction(); % no input arguments
else
error('unexpected number of input arguments for function %s',func2str(initfunction));
end
else else
error('initfunction must be a string or a function handle') error('initfunction must be a string or a function handle')
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment