Documentation

setProperties

Class: matlab.System
Package: matlab

Set property values using name-value pairs

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.

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

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

collapse 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.

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