nelson.mixin.SetGet
Add set and get property access to a handle class.
📝Syntax
classdef MyClass < nelson.mixin.SetGet
set(obj, name, value)
value = get(obj, name)
📥Input Arguments
Parameter Description
obj a handle object of a class deriving from nelson.mixin.SetGet.
name a property name (char or string), or a cell array of names.
value the value to assign.
📤Output Arguments
Parameter Description
value the property value.
📄Description

Derive a handle class from nelson.mixin.SetGet to give it set and get methods for reading and writing properties by name.

set(obj, name, value) assigns a property; set(obj, n1, v1, n2, v2, ...) assigns several. get(obj, name) returns a property value; get(obj) returns a structure of all properties. Property names are matched case-insensitively.

💡Examples
Name-based property access.
classdef Widget < nelson.mixin.SetGet
  properties
    Width = 0
    Height = 0
  end
end
w = Widget();
set(w, 'Width', 100, 'Height', 40);
get(w, 'Width')
🔗See Also
handlenelson.mixin.SetGetExactNamesclassdef
🕔Version History
Version Description
2.0.0 initial version
Edit this page on GitHub