Main Content

getOutputDataType

Get data types of the outputs of a System object

    Description

    [dt_1, dt_2, ..., dt_n] = getOutputDataType(obj) returns the data type of each output of the System object™ as a character vector for built-in data types or as a numeric object for fixed-point data types. The number of outputs must match the number of outputs returned by the getNumOutputs method.

    example

    Examples

    collapse all

    Call getOutputDataType to get the data types of the outputs 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
        end
    
    end

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

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

    Call getOutputDataType to get the data types of the outputs.

    [dt_1, dt_2] = getOutputDataType(a);

    Input Arguments

    collapse all

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

    Output Arguments

    collapse all

    Data type of output. For built-in data types, dt is a character vector. For fixed-point data types, dt is a numeric type object.

    Version History

    Introduced in R2012a