getDiscreteStateSpecification - Get the size, data type, and complexity of the discrete state of a System object - MATLAB (original) (raw)

Get the size, data type, and complexity of the discrete state of a System object

Syntax

Description

[[size](#mw%5Ffcd514b7-82de-40c6-b107-07c1125507e4),[dataType](#mw%5Feadd5459-5481-4c3e-b110-c88002503fe2),[complexity](#mw%5Fd80f48cd-d07d-4f0e-89e3-fcb52a88d98c)] = getDiscreteStateSpecification([obj](#mw%5Fde91d360-3f6e-46dd-ac06-c3fd6b512420),[propertyName](#mw%5F1d8528d9-5b31-4288-83f0-dec260a15797)) returns the size, data type, and complexity of the discrete state property. This property must be a discrete state property.

example

Examples

collapse all

Call getDiscreteStateSpecification to get the size, data type, and complexity of the discrete state of a System object™.

Consider a System object object defined as,

classdef UnitDelay < matlab.System % UnitDelayNondirect Delay input by one time step

properties(DiscreteState) State Step end

methods(Access = protected)
    function resetImpl(obj)
        obj.State = 0; % Initialize states
        obj.Step = 1;
    end
   
    function [y1, y2] = stepImpl(obj,u)
        y1 = obj.State; % Output current state
        y2 = obj.Step; 
        
        obj.State = u;
        obj.Step = obj.Step + 1; 
    end

    function [sz1, sz2] = getOutputSizeImpl(obj)
        sz1 = [1,1]; % Specify size of output port
        sz2 = [1,1]; 
    end

    function [flag1, flag2] = isOutputFixedSizeImpl(obj)
        flag1 = true; % Specify if output is fized size
        flag2 = true;
    end

    function [c1, c2] = getOutputDataTypeImpl(obj)
        c1 = 'double'; % Specify output datatype
        c2 = 'double'; 
    end 

    function [c1, c2] = isOutputComplexImpl(obj)
        c1 = false;   % Specify if output is complex
        c2 = false; 
    end

    function [sz,dt,cp] = getDiscreteStateSpecification(obj,name)
        sz = [1 1];
        dt = "double";
        cp = false;
    end

end

Create an instance of the System object and provide it with an input.

a = UnitDelay(); [out, step] = a(1);

Call getDiscreteStateSpecification to check the specification of the 'Step' state.

[sz,dt,cp] = getDiscreteStateSpecification(a,"Step");

Input Arguments

collapse all

System object handle used to access properties, states, and methods specific to the object.

Name of discrete state property of the System object

Output Arguments

collapse all

Vector containing the length of each dimension of the property.

Data type of the property. For built-in data types, dataType is a character vector. For fixed-point data types, dataType is a numeric type object.

Complexity of the property as a scalar, logical value:

Version History

Introduced in R2012a