MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1

Define Property Attributes


This example shows how to specify property attributes.

Property attributes, which add details to a property, provide a layer of control to your
properties. In addition to the MATLAB property attributes, System objects can use these
three additional attributes: Nontunable, Logical, and PositiveInteger. To specify
multiple attributes, separate them with commas.

Specify Property as Nontunable

Use the Nontunable attribute for a property when the algorithm depends on the value
being constant once data processing starts. Defining a property as nontunable may
improve the efficiency of your algorithm by removing the need to check for or react to
values that change. For code generation, defining a property as nontunable allows the
memory associated with that property to be optimized. You should define all properties
that affect the number of input or output ports as nontunable.

Users of the System object can only change nontunable properties before calling the
object or after calling the release function. In this example, you define the
InitialValue property as nontunable and set its value to 0.

properties (Nontunable)
InitialValue = 0;
end

Specify Property as Logical

Logical properties have the value true or false. System object users can enter 1 or 0 or
any value that can be converted to a logical. The value, however, displays as true or
false. You can use sparse logical values, but they must be scalar values. In this example,
the Increment property indicates whether to increase the counter. By default,
Increment is tunable property. The following restrictions apply to a property with the
Logical attribute,


  • Cannot also be Dependent or PositiveInteger

  • Default value must be true or false. You cannot use 1 or 0 as a default value.


properties (Logical)
Increment = true
end

34 System object Usage and Authoring

Free download pdf