Outport

Create output port for subsystem or external output

  • Library:
  • Simulink / Commonly Used Blocks

    Simulink / Ports & Subsystems

    Simulink / Sinks

    HDL Coder / Commonly Used Blocks

    HDL Coder / Ports & Subsystems

    HDL Coder / Sinks

  • Outport block

Description

Outport blocks link signals from a system to a destination outside of the system. They can connect signals flowing from a subsystem to other parts of the model. They can also supply external outputs at the top level of a model hierarchy.

Simulink® software assigns Outport block port numbers according to these rules:

  • It automatically numbers the Outport blocks within a root-level system or subsystem sequentially, starting with 1.

  • If you add an Outport block, it is assigned the next available number.

  • If you delete an Outport block, other port numbers are automatically renumbered to ensure that the Outport blocks are in sequence and that no numbers are omitted.

Outport Blocks in a Subsystem

Outport blocks in a subsystem represent outputs from the subsystem. A signal arriving at an Outport block in a subsystem flows out of the associated output port on that Subsystem block. The Outport block associated with an output port is the block whose Port number parameter matches the relative position of the output port on the Subsystem block. For example, the Outport block whose Port number parameter is 1 sends its signal to the block connected to the topmost output port on the Subsystem block.

If you renumber the Port number of an Outport block, the block becomes connected to a different output port. The block continues to send the signal to the same block outside the subsystem.

Tip

For models that include bus signals composed of many bus elements, consider using In Bus Element and Out Bus Element blocks. These blocks:

  • Reduce signal line complexity and clutter in a block diagram.

  • Make it easier to change the interface incrementally.

  • Allow access to a bus element closer to the point of usage, avoiding the use of a Bus Selector and Goto block configuration.

The In Bus Element block is of block type Inport and the Out Bus Element block is of block type Outport.

Top-Level Outport Block in a Model Hierarchy

Outport blocks at the top level of a model hierarchy have two uses. They can supply external outputs to the base MATLAB® workspace, and they provide a means for the linmod and trim analysis functions to obtain output from the system.

To supply external outputs to the workspace, use the Configuration Parameters > Data Import/Export pane (see Exporting Output Data to the MATLAB Workspace) or the sim command. For example, if a system has more than one Outport block and the save format is array, the following command

[t,x,y] = sim(...);

writes y as a matrix, with each column containing data for a different Outport block. The column order matches the order of the port numbers for the Outport blocks.

If you specify more than one variable name after the second (state) argument, data from each Outport block is written to a different variable. For example, if the system has two Outport blocks, to save data from Outport block 1 to speed and the data from Outport block 2 to dist, specify this command:

[t,x,speed,dist] = sim(...);

Connecting Buses to Root-Level Outports

A root-level Outport block in a model can accept a virtual bus only if all elements of the bus have the same data type. The Outport block automatically unifies the bus to a vector having the same number of elements as the bus, and provides that vector as output.

If you want a root-level Outport of a model to accept a bus signal that contains mixed types, set Outport block Data type to Bus: <object name>. If the bus signal is virtual, it is converted to nonvirtual, as described in Virtual and Nonvirtual Bus Conversions.

Associate Root-Level Outport Block with Simulink.Signal Object

To associate a root-level Outport block with a Simulink.Signal object, use the Model Data Editor. See For Signals.

Ports

Input

expand all

Input signal that flows through the outport to an external subsystem or model.

An Outport block can accept fixed-point and enumerated data types when the block is not a root-level output port. The complexity and data type of the block output are the same as its input.

Data Types: half | single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | string | Boolean | fixed point | enumerated | bus

Parameters

expand all

Main

Specify the order in which the port that corresponds to the block appears on the parent Subsystem or Model block.

  • If you add a block that creates another port, the port number is the next available number.

  • Deleting all blocks associated with a port deletes the port. Other ports are renumbered so that they are sequential and do not skip any numbers.

  • Specifying a port number that exceeds the number of ports creates a port for that number and for any skipped sequential numbers.

Programmatic Use

Block Parameter: Port
Type: character vector
Values: real integer
Default: '1'

Specify the name of the corresponding signal data in the generated code. Use this parameter to specify a name for the signal data when you apply a storage class to a root-level Outport block.

Programmatic Use

Block Parameter: SignalName
Type: character vector
Values: character vector
Default: ' '

Specify the information displayed on the block icon.

Programmatic Use

Block Parameter: IconDisplay
Type: character vector
Values: 'Signal name' | 'Port number' | 'Port number and signal name'
Default: 'Port number'

Specify a constant output value for when source is not connected.

Dependency

Available for unconnected Outport blocks inside a Variant Subsystem block.

Programmatic Use

Block Parameter: OutputWhenUnconnected
Type: character vector
Values: 'on' | 'off'
Default: 'off'

Specify a constant output value for when source is not connected.

Dependency

Available in a Variant Subsystem block for an unconnected Outport block with Specify output when source is unconnected selected.

Programmatic Use

Block Parameter: OutputWhenUnconnectedValue
Type: character vector
Values: scalar | vector
Default: '0'

Select this check box to create a vector of length N at the output if the Constant value parameter evaluates to an N-element row or column vector.

Dependency

Available in a Variant Subsystem block on an unconnected Outport block when you select the Specify output when source is unconnected parameter.

Programmatic Use

Block Parameter: VectorParamsAs1DForOutWhenUnconnected
Type: character vector
Values: 'on' | 'off'
Default: 'on'

Clear this check box to specify that Simulink uses a signal buffer on output port. This buffer ensures consistent initialization of the Outport block signal.

If you select this check box, Simulink tries to remove the signal buffer.

  • If the signal buffer is not needed, Simulink removes the buffer.

  • If the signal buffer is needed for data consistency and proper execution, Simulink displays an error indicating the buffer could not be removed.

Allow partial writes through Assignment blocks.

For examples with conditional writes and partial writes, see Ensure Outport is Virtual.

Dependency

This parameter applies to these blocks:

  • Conditional subsystem

  • Assignment

  • Merge

  • Model with root Outport block

Programmatic Use

Block Parameter: EnsureOutportIsVirtual
Type: character vector
Values: 'on' | 'off'
Default: 'off'

Select the source of the initial output value of the block. Select Dialog to specify that the initial output value is the value of the Initial output parameter. Select Input signal to specify that the initial output value is inherited from the input signal. See Conditional Subsystem Initial Output Values.

Tips

  • If you are using classic initialization mode, selecting Input signal causes an error. To inherit the initial output value from the input signal, set this parameter to Dialog and specify [] (empty matrix) for the Initial output value. For more information, see Conditional Subsystem Initial Output Values.

Dependencies

Available for Outport blocks inside a conditional subsystem.

Selecting Dialog exposes the following parameters:

  • Output when disabled

  • Initial output

Programmatic Use

Block Parameter: SourceOfInitialOutputValue
Type: character vector
Values: 'Dialog' | 'Input signal'
Default: 'Dialog'

Specify what happens to the block output when the subsystem is disabled. Select held to indicate that the output is held when the subsystem is disabled. Select reset to indicate that the output is reset to the value given by Initial output when the subsystem is disabled.

Dependencies

Available when you select Dialog as the value for the Source of initial output parameter for an Outport block inside a conditional subsystem with valid enabling and disabling semantics. For example, the parameter is available for an Outport block inside an Enabled Subsystem block and not for an Outport block inside a Triggered Subsystem block.

If an Outport block is inside a Function-Call Subsystem block, this parameter is only meaningful if the Function-Call Subsystem block is connected to a state in a Stateflow® chart. For more information, see Bind a Function-Call Subsystem to a State (Stateflow).

When connecting the output of a conditional subsystem to a Merge block, set this parameter to held. Setting it to reset returns an error.

Programmatic Use

Block Parameter: OutputWhenDisabled
Type: character vector
Values: 'held' | 'reset'
Default: 'held'

For conditionally executed subsystems, specify the block output before the subsystem executes and while it is disabled. Specify [] to inherit the initial output value from the input signal. For more information, see Conditional Subsystem Initial Output Values.

For information about specifying an initial condition structure, see Specify Initial Conditions for Bus Signals.

Tips

If the conditional subsystem is driving a Merge block, you do not need to specify an Initial Condition (IC) for the Outport block. For more information, see Underspecified initialization detection.

Dependencies

Available when Source of initial output value is set to Dialog for an Outport block in a conditional subsystem.

Limitations

  • This block does not allow an initial output of inf or NaN.

  • When the input is a virtual bus, an Initial output value [] is treated as double(0).

  • When the input contains a nonvirtual bus, Initial output does not support nonzero scalar values.

Programmatic Use

Block Parameter: InitialOutput
Type: character vector
Values: '[]' | scalar | structure
Default: '[]'

Signal Attributes

Click the Show data type assistant button to display the Data Type Assistant, which helps you set the data type attributes. For more information, see Specify Data Types Using Data Type Assistant.

Lower value of the output range that Simulink checks.

This number must be a finite real double scalar value.

Note

If you specify a bus object as the data type for this block, do not set the minimum value for bus data on the block. Simulink ignores this setting. Instead, set the minimum values for bus elements of the bus object specified as the data type. For information on the Minimum property of a bus element, see Simulink.BusElement.

Simulink software uses this value to perform:

  • Simulation range checking (see Specify Signal Ranges).

  • Automatic scaling of fixed-point data types.

  • Optimization of the code that you generate from the model. This optimization can remove algorithmic code and affect the results of some simulation modes such as SIL or external mode. For more information, see Optimize using the specified minimum and maximum values (Embedded Coder).

Programmatic Use

Block Parameter: OutMin
Type: character vector
Values: '[ ]'| scalar
Default: '[ ]'

Upper value of the output range that Simulink checks.

This number must be a finite real double scalar value.

Note

If you specify a bus object as the data type for this block, do not set the maximum value for bus data on the block. Simulink ignores this setting. Instead, set the maximum values for bus elements of the bus object specified as the data type. For information on the Maximum property of a bus element, see Simulink.BusElement.

Simulink software uses this value to perform:

  • Simulation range checking (see Specify Signal Ranges).

  • Automatic scaling of fixed-point data types.

  • Optimization of the code that you generate from the model. This optimization can remove algorithmic code and affect the results of some simulation modes such as SIL or external mode. For more information, see Optimize using the specified minimum and maximum values (Embedded Coder).

Programmatic Use

Block Parameter: OutMax
Type: character vector
Values: '[ ]'| scalar
Default: '[ ]'

Specify the output data type of the external input. The type can be inherited, specified directly, or expressed as a data type object such as Simulink.NumericType.

Tips

You cannot enter the name of a Simulink.Bus object as a data type expression. To specify the Data type for the block using a Bus object, select the Bus: <object name> option and replace <object name> with the name of the Bus object.

Programmatic Use

Block Parameter: OutDataTypeStr
Type: character vector
Values: 'Inherit: auto' | 'double' | 'single' | 'half' | 'int8' | 'uint8' | 'int16' | 'uint16' | 'int32' | 'uint32' | 'int64' | 'uint64' | 'boolean' | 'fixdt(1,16)' | 'fixdt(1,16,0)' | 'fixdt(1,16,2^0,0)' | 'string' | 'Enum: <class name>' | 'Bus: <object name>' | '<data type expression>'
Default: 'Inherit: auto'

Select to lock the output data type setting of this block against changes by the Fixed-Point Tool and the Fixed-Point Advisor. For more information, see Use Lock Output Data Type Setting (Fixed-Point Designer).

Programmatic Use

Block Parameter: LockScale
Type: character vector
Values: 'off' | 'on'
Default: 'off'

Specify the outport bus to be nonvirtual in the parent model. Select this parameter if you want the bus emerging in the parent model to be nonvirtual. The bus that is input to the port can be virtual or nonvirtual, regardless of the setting of Output as nonvirtual bus in parent model.

Clear this parameter if you want the bus emerging in the parent model to be virtual.

Tips

  • In a nonvirtual bus, all signals must have the same sample time, even if the elements of the associated bus object specify inherited sample times. Any operation that would result in a nonvirtual bus that violates this requirement generates an error. For details, see Rate Transitions for Nonvirtual Buses.

    To use a multirate signal for a virtual bus, in the root-level Outport block, set the Sample time parameter to inherited (-1).

  • For the top model in a model reference hierarchy, code generation creates a C structure to represent the bus signal output of this block.

  • For referenced models, select this option to create a C structure. Otherwise, code generation creates an argument for each leaf element of the bus.

Dependency

Available when the Data type is set to Bus: <object name>.

Programmatic Use

Block Parameter: BusOutputAsStruct
Type: character vector
Values: 'off' | 'on'
Default: 'off'

Specify the physical unit of the input signal to the block. To specify a unit, begin typing in the text box. As you type, the parameter displays potential matching units. For a list of supported units, see Allowed Unit Systems.

To constrain the unit system, click the link to the right of the parameter:

  • If a Unit System Configuration block exists in the component, its dialog box opens. Use that dialog box to specify allowed and disallowed unit systems for the component.

  • If a Unit System Configuration block does not exist in the component, the model Configuration Parameters dialog box displays. Use that dialog box to specify allowed and disallowed unit systems for the model.

Programmatic Use

Block Parameter: Unit
Type: character vector
Values: 'inherit' | '<Enter unit>'
Default: 'inherit'

Specify the dimensions that a signal must have to be connected to this Outport block.

-1

A signal of any dimensions can be connected to this port.

N

The signal connected to this port must be a vector of size N.

[R C]

The signal connected to this port must be a matrix having R rows and C columns.

Programmatic Use

Block Parameter: PortDimensions
Type: character vector
Values: '-1' | integer | [integer, integer]
Default: '-1'

Specify the type of signals allowed at the output of this port. To allow variable-size and fixed-size signals, select Inherit. To allow only variable-size signals, select Yes. To allow only fixed-size signals, select No.

Dependencies

When the signal at this port is a variable-size signal, the Port dimensions parameter specifies the maximum dimensions of the signal.

Command-Line Information

Parameter: VarSizeSig
Type: character vector
Value: 'Inherit' | 'No' | 'Yes'
Default: 'Inherit'

Specify the discrete interval between sample time hits or specify another appropriate sample time such as continuous or inherited.

By default, the block inherits its sample time based upon the context of the block within the model. To set a different sample time, enter a valid sample time based upon the table in Types of Sample Time.

Programmatic Use

Block Parameter: SampleTime
Type: character vector
Values: scalar
Default: '-1'

Specify the numeric type of the signal output. To choose the numeric type of the signal that is connected to its input, select auto. Otherwise, choose a real or complex signal type.

Programmatic Use

Block Parameter: SignalType
Type: character vector
Values: 'auto' | 'real' | 'complex'
Default: 'auto'

Block Characteristics

Data Types

Boolean | bus | double | enumerated | fixed point | half | integer | single | string

Direct Feedthrough

no

Multidimensional Signals

yes

Variable-Size Signals

yes

Zero-Crossing Detection

no

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

PLC Code Generation
Generate Structured Text code using Simulink® PLC Coder™.

Fixed-Point Conversion
Design and simulate fixed-point systems using Fixed-Point Designer™.

Introduced before R2006a