From: per isakson on 1 Dec 2009 23:05 There must be a better solution to this problem. I want a validator to use with inputParser that combine two or more functions, which don't return any argument, e.g. validateattributes. This is my solution is >> test ??? Error using ==> test at 11 Argument 'maxHeight' failed validation with error: Expected input to be even. where function test %% fh1 = @(x) validateattributes( x, {'double'}, {'odd'} ); fh2 = @(x) validateattributes( x, {'double'}, {'even'} ); %% validator = @(x) check4exception( x, fh1, fh2 ); %% ip = inputParser; ip.addParamValue( 'maxHeight', 2, validator ) %% ip.parse( 'maxHeight', 1 ) end and where function check4exception( val, varargin ) for ca = varargin ca{1}( val ); end end / per
|
Pages: 1 Prev: setting color with data Next: ode45 to plot state space variables..help!! |