Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- funtion out1 = func1(arg1, arg2, varargin)
- % function out1 = func1(arg1, arg2)
- % function out1 = func1(_____, 'param1', value)
- % function out1 = func1(_____, 'param2', value)
- ni = length(varargin); % ni >= 1
- DataInputs = 0;
- PNVStart = 0; % index of the first parameter in varargin
- % Assuming none of the preceding arguments arg1 and arg2 are strings (char row vectors)
- while DataInputs<ni && PNVStart==0
- nextarg = varargin{DataInputs+1};
- if ischar(nextarg) && isvector(nextarg)
- PNVStart = DataInputs+1;
- else
- DataInputs = DataInputs+1;
- end
- end
- % Initialize
- param1 = [];
- param2 = [];
- for i=PNVStart:2:ni
- % Set each Property Name/Value pair in turn.
- Property = varargin{i};
- if i+1>ni
- error('id:pvsetInvalid', 'message')
- else
- Value = varargin{i+1};
- end
- % Perform assignment
- switch lower(Property)
- case 'param1'
- if ~isempty(Value) && ischar(Value) && isrow(Value) % put whatever expression to verify Value
- variable1 = Value;
- else
- error('id:pvsetInvalid:variable1', 'message')
- end
- case 'param2'
- if ~isempty(Value) && ischar(Value) && isrow(Value)
- variable2 = Value;
- else
- error('id:pvsetInvalid:variable2', 'message')
- end
- otherwise
- error('id:pvsetInvalid', 'message')
- end % switch
- end % for
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement