Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

getOutputDataTypeImpl

Class: matlab.system.mixin.Propagates
Package: matlab.system.mixin

Data types of output ports

Syntax

[dt_1,dt_2,...,dt_n] = getOutputDataTypeImpl(obj)

Description

[dt_1,dt_2,...,dt_n] = getOutputDataTypeImpl(obj) returns the data type of each output port 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 value returned from the getNumOutputs method or the number of output arguments listed in the stepImpl method.

For System objects with one input and one output and where you want the input and output data types to be the same, you do not need to implement this method. In this case, getOutputDataTypeImpl assumes the input and output data types are the same and returns the data type of the input.

If your System object™ has more than one input or output, and you subclass from matlab.system.mixin.Propagates, you must set the output data types in the getOutputDataTypeImpl method. For Simulink®, if the input and output data types are different, you might have to cast the output value to the data type of the appropriate dt_n output argument. You specify this casting in the stepImpl method. For bus output, you must specify the name of the output bus in getOutputDataTypeImpl.

If needed to determine the output data type, you can use propagatedInputDataType within the getOutputDataTypeImpl method to obtain the input type.

    Note:   You must set Access = protected for this method.

    You cannot modify any properties in this method.

    If you are debugging your code and examine the data types before Simulink completes propagation, you might see outputs with empty, [ ], data types. This occurs because Simulink has not completed setting the output data types.

Input Arguments

obj

System object

Output Arguments

dt_1,dt_2,...

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

Examples

expand all

Specify, in your class definition file how to control the output data type from a MATLAB® System block. This example shows how to use the getOutputDataTypeImpl method to change the output data type from single to double, or propagate the input as a double. It also shows how to cast the data type to change the output data type in the stepImpl method.

classdef DataTypeChange < matlab.System & ...
  matlab.system.mixin.Propagates

   properties(Nontunable)
      Quantize = false
   end

   methods(Access = protected)
      function y = stepImpl(obj,u)
         if obj.Quantize == true
            % Cast for output data type to differ from input.
            y = single(u);
         else
            % Propagate output data type.
            y = u;
         end
      end

      function out = getOutputDataTypeImpl(obj)
         if obj.Quantize == true
            out = 'single';
         else
            out = propagatedInputDataType(obj,1);
         end
      end
   end
end

Specify, in your class definition file, that the System object data type is a bus. You must also include a property to specify the bus name.

properties(Nontunable)
   OutputBusName = 'myBus'
end

methods (Access = protected)
   function out = getOutputDataTypeImpl(obj)
      out = obj.OutputBusName;
   end
end
Was this topic helpful?