setProperties

Class: matlab.System
Package: matlab

Set property values from name-value pair inputs

Syntax

setProperties(obj,numargs,name1,value1,name2,value2,...)
setProperties(obj,numargs,arg1,...,argm,name1,value1,name2,value2,...,'ValueOnlyPropName1','ValueOnlyPropName2',...,'ValueOnlyPropNamem')

Description

setProperties(obj,numargs,name1,value1,name2,value2,...) provides the name-value pair inputs to the System object™ constructor. Use this syntax if every input must specify both name and value.

    Note:   To allow standard name-value pair handling at construction, define setProperties for your System object.

setProperties(obj,numargs,arg1,...,argm,name1,value1,name2,value2,...,'ValueOnlyPropName1','ValueOnlyPropName2',...,'ValueOnlyPropNamem') provides the value-only inputs, followed by the name-value pair inputs to the System object during object construction. Use this syntax if you want to allow users to specify one or more inputs by their values only.

Input Arguments

obj

System object handle

numargs

Number of inputs passed in by the object constructor

name1,name2,...

Name of property

value1,value2,...

Value of the property

arg1,arg2,...

Value of property (for value-only input to the object constructor)

ValueOnlyPropName1,ValueOnlyPropName2,...

Name of the value-only property

Examples

expand all

Setup Value-Only Inputs

Set up an object so users can specify value-only inputs for VProp1, VProp2, and other property values via name-value pairs when constructing the object. In this example, VProp1 and VProp2 are the names of value-only properties.

methods
   function obj = MyFile(varargin)
      setProperties(obj,nargin,varargin{:},'VProp1','VProp2');
   end
end
Was this topic helpful?