How can I validate a function handle as an input argument?
I have a class that has a function handle as one of its properties . classdef MyClass properties hfun %function handle end methods function obj = Myclass(hfun,...) %PROBLEM: validate that the input argument hfun is the right kind of function if ~isa(hfun,'function_handle') || nargin(hfun)~=1 || nargout(hfun)~=1 error('hfun must be a function handle with 1 input and 1 output'); end obj.hfun = hfun; end end end I'd like to make sure that the input argument hfun is a function handle with 1 input and 1 output, otherwise it should error. If I could get even more specific I'd like this function to