Main Content

Outport

Create output port for subsystem or external output

  • Outport block

Libraries:
Simulink / Commonly Used Blocks
Simulink / Ports & Subsystems
Simulink / Sinks
HDL Coder / Commonly Used Blocks
HDL Coder / Ports & Subsystems
HDL Coder / Sinks

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.

Outport block port numbers are assigned according to these rules:

  • Outport blocks within a root-level system or subsystem are numbered 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.

You can directly edit port labels on a Subsystem block. For more information, see Edit Port Labels on Subsystem Blocks.

Tip

For models that include buses 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, this 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 block of a model to accept a bus that contains mixed types, set the Outport block Data type to Bus: <object name>. If the bus 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 | image

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

To set the block parameter value programmatically, use the set_param function.

Parameter: Port
Values: '1' (default) | real integer in quotes
Data Types: char | string

Example: set_param('mymodel/Subsystem1/PortBlock','Port','5')

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.

Dependencies

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.

Dependencies

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.

Dependencies

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 parameter to allow Simulink® to use a signal buffer on output port. This buffer, which is the equivalent of a Signal Copy block but is not displayed on the canvas, ensures consistent initialization of the Outport block signal.

If you select this parameter, 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 more information regarding this parameter, including examples with conditional writes and partial writes, see Ensure Output Port Is Virtual.

Dependencies

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.

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 Elements.

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

Lower value of the output range that the software checks.

This number must be a finite real double scalar value.

The 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).

Dependencies

The software ignores the value of this parameter when Data type specifies a Simulink.ValueType or Simulink.Bus object. The software uses the minimum values specified by the Simulink.ValueType object or the Simulink.BusElement objects in the Simulink.Bus object instead.

Programmatic Use

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

Upper value of the output range that the software checks.

This number must be a finite real double scalar value.

The 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).

Dependencies

The software ignores the value of this parameter when Data type specifies a Simulink.ValueType or Simulink.Bus object. The software uses the maximum values specified by the Simulink.ValueType object or the Simulink.BusElement objects in the Simulink.Bus object instead.

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 a Simulink.NumericType object.

The Data Type Assistant helps you set data attributes. To use the Data Type Assistant, click the Show data type assistant button. For more information, see Specify Data Types Using Data Type Assistant.

You can specify any of these options:

  • Inherited data type

  • Built-in Simulink data type — For example, specify single or uint8. See Data Types Supported by Simulink.

  • Fixed-point data type — Use the fixdt function. For example, specify fixdt(1,16,0).

  • Enumerated data type — Use the name of the type preceded by Enum:. For example, specify Enum: myEnumType.

  • Bus data type — Use the name of the Simulink.Bus object preceded by Bus:. For example, specify Bus: myBusObject.

  • Simulink image data type — If you have Computer Vision Toolbox™, use the constructor for the Simulink.ImageType (Computer Vision Toolbox) object and specify the properties to describe the image. By default, the data type uses the Simulink.ImageType(480,640,3) expression that represents the rows, columns, and channels of the image respectively.

  • Value type — Use the name of the Simulink.ValueType object preceded by ValueType:. For example, specify ValueType: windVelocity.

  • Custom data type — Use a MATLAB expression that specifies the type. For example, you can specify a Simulink.NumericType object whose DataTypeMode property is set to a value other than 'Fixed-point: unspecified scaling'.

When you specify a Simulink.ValueType or Simulink.Bus object as the data type, some parameters of the Outport block are ignored. For example, the Min, Max, and Unit parameters of the Outport block are ignored. The software uses the corresponding properties of the Simulink.ValueType object or the Simulink.BusElement objects in the Simulink.Bus object instead. For example, suppose a block sets Unit to ft/s. When the Data type of the block specifies a ValueType object that has m/s as its unit, the block uses m/s instead of ft/s.

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>' | 'ValueType: <object name>' | '<data type expression>' | Simulink.ImageType(480,640,3)
Default: 'Inherit: auto'

Select this parameter to prevent the fixed-point tools from overriding the output data type you specify on the block. For more information, see Use Lock Output Data Type Setting (Fixed-Point Designer).

Dependencies

The software ignores the value of this parameter when Data type specifies a Simulink.ValueType object.

Programmatic Use

Block Parameter: LockScale
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 Modify Sample Times 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 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.

Dependencies

To enable this parameter, Data type must resolve to a Simulink.Bus object. For example, set Data type to a Simulink.Bus object or a Simulink.ValueType object that specifies a Simulink.Bus object as its data type.

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.

Dependencies

The software ignores the value of this parameter when Data type specifies a Simulink.ValueType or Simulink.Bus object. The software uses the units specified by the Simulink.ValueType object or the Simulink.BusElement objects in the Simulink.Bus object instead.

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.

Dependencies

The software ignores the value of this parameter when Data type specifies a Simulink.ValueType object. The software uses the dimensions specified by the Simulink.ValueType object instead.

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.

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

Dependencies

The software ignores the value of this parameter when Data type specifies a Simulink.ValueType object. The software uses the dimensions mode specified by the Simulink.ValueType object instead.

Programmatic Use

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

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.

Dependencies

The software ignores the value of this parameter when Data type specifies a Simulink.ValueType or Simulink.Bus object. The software uses the complexity specified by the Simulink.ValueType object or the Simulink.BusElement objects in the Simulink.Bus object instead.

Programmatic Use

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

Execution

Specify the discrete interval between sample time hits or specify another type of sample time, such as continuous (0) or inherited (-1). For more options, see Types of Sample Time.

By default, the block inherits its sample time based upon the context of the block within the model.

Programmatic Use

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

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™.

Version History

Introduced before R2006a

expand all