Main Content

getOutputSizeImpl

Class: matlab.System

Sizes of output ports

Syntax

[sz_1,sz_2,...,sz_n] = getOutputSizeImpl(obj)

Description

[sz_1,sz_2,...,sz_n] = getOutputSizeImpl(obj) returns the size of each output port. The number of outputs must match the value returned from the getNumOutputs method or the number of output arguments listed in the stepImpl method.

If your System object™ has only one input and one output and you want the input and output sizes to be the same, you do not need to implement this method. In this case getOutputSizeImpl assumes that the input and output sizes are the same and returns the size of the input. For variable-size inputs in MATLAB®, the size varies each time you run your object. For variable-size inputs in Simulink®, the output size is the maximum input size.

You must implement the getOutputSizeImpl method to define the output size, if:

  • Your System object has more than one input or output

  • You need the output and input sizes to be different.

    If the output size differs from the input size, you must also use the propagatedInputSize method

By default, in Simulink the MATLAB System (Simulink) block recognizes 1-D input signals and propagates 1-D output signal as 2-D. Use supports1DVectorsImpl method to enable the 1-D inputs and outputs to be recognized and propagated as 1-D signals, respectively.

Run-Time Details

During Simulink model compilation and propagation, the MATLAB System (Simulink) block calls the getOutputSizeImpl method to determine the output size.

All inputs default to variable-size inputs For these inputs, the output size is the maximum input size.

Method Authoring Tips

  • You must set Access = protected for this method.

  • In this method, you cannot modify any properties.

Input Arguments

expand all

System object handle used to access properties, states, and methods specific to the object. If your getOutputSizeImpl method does not use the object, you can replace this input with ~.

Output Arguments

expand all

Vector containing the size of each output port.

Examples

expand all

Specify in your class definition file the size of a System object output.

methods (Access = protected)
   function sz_1 = getOutputSizeImpl(obj)
      sz_1 = [1 1];
   end 
end

Specify in your class definition file the sizes of multiple System object outputs.

methods (Access = protected)
   function [sz_1,sz_2] = getOutputSizeImpl(obj) 
      sz_1 = propagatedInputSize(obj,1); 
      sz_2 = [1 1]; 
   end
 end 

Specify in your class definition file the size of System object output when it depends on the propagated input size.

methods (Access = protected)
   function varargout = getOutputSizeImpl(obj) 
      varargout{1} = propagatedInputSize(obj,1); 
      if obj.HasSecondOutput
         varargout{2} = [1 1];
      end
   end
end 

Version History

Introduced in R2013b

See Also

Topics