getDiscreteState - Get the discrete states of a System object - MATLAB (original) (raw)
Main Content
Get the discrete states of a System object
Syntax
Description
[discreteStates](#mw%5F46a13392-190a-4789-bd27-4019a7dfd4cc)= getDiscreteState([obj](#mw%5F5a5bce7c-f439-4cb0-9b29-cc987ba682d3))
returns a struct discreteStates
of internal state value properties, which have the DiscreteState
attribute. The field names of the struct are the object’s DiscreteState
property names. You can restrict or change the values returned by getDiscreteState method by overwriting the getDiscreteStateImpl method.
Examples
Get Discrete State Values
Use the getDiscreteStateImpl method in your class definition file to customize the behavior of getDiscreteState method. The System object contains discrete states value
and power
. A nontunable parameter keepTrack
determines the states displayed by this method.
Declare the behavior of getDiscreteState using getDiscreteStateImpl method in the class definition file.
methods (Access = protected) function s = getDiscreteStateImpl(obj) if obj.keepTrack s.value = obj.value; s.power = obj.power; else s.value = obj.value; end end end
Use getDiscreteState to access the discrete states of the method.
discreteStates = getDiscreteState(obj);
Input Arguments
obj
— System object™
System object
System object handle used to access properties, states, and methods specific to the object.
Output Arguments
discreteStates
— Discrete state values
struct
Discrete state values returned as a struct.
Version History
Introduced in R2012b