MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1

Specify Property as Positive Integer


In this example, the private property MaxValue is constrained to accept only real,
positive integers. You cannot use sparse values. The following restriction applies to a
property with the PositiveInteger attribute,



  • Cannot also be Dependent or Logical


properties (PositiveInteger)
MaxValue
end


Specify Property as DiscreteState


If your algorithm uses properties that hold state, you can assign those properties the
DiscreteState attribute. Properties with this attribute display their state values via the
getDiscreteStateImpl when users call getDiscreteState. The following
restrictions apply to a property with the DiscreteState attribute,



  • Numeric, logical, or fi value, but not a scaled double fi value

  • Does not have any of these attributes: Nontunable, Dependent, Abstract,
    Constant.

  • No default value

  • Not publicly settable

  • GetAccess = Public by default

  • Value set only via the setupImpl when the System object is called. (See “Summary of
    Call Sequence” on page 34-59)


In this example, you define the Count property as a discrete state:


properties (DiscreteState)
Count;
end


Complete Class Definition File with Property Attributes


classdef Counter < matlab.System
% Counter Increment a counter to a maximum value


% These properties are nontunable. They cannot be changed
% after the setup method has been called or while the


Define Property Attributes
Free download pdf