Main Content

Inport

Create input port for subsystem or external input

  • Library:
  • Simulink / Commonly Used Blocks

    Simulink / Ports & Subsystems

    Simulink / Sources

    HDL Coder / Commonly Used Blocks

    HDL Coder / Ports & Subsystems

    HDL Coder / Sources

  • Inport block

Description

Inportblocks link signals from outside a system into the system.

金宝app®software assignsInportblock port numbers according to these rules:

  • It automatically numbers theInportblocks within a top-level system or subsystem sequentially, starting with 1.

  • If you add anInportblock, the label is the next available number.

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

  • If you copy anInportblock into a system, its port number isnotrenumbered unless its current number conflicts with an inport already in the system. If the copiedInportblock port number is not in sequence, renumber the block. Otherwise, you get an error message when you run the simulation or update the block diagram.

Inport Blocks in a Top-Level System

You can use anInportblock in a top-level system to:

  • Supply external inputs from the workspace using one of these approaches. If no external outputs are supplied, then the default output is the ground value.

  • Provide a means for perturbation of the model by thelinmodandtrimanalysis functions.

  • To load logged signal data using rootInportblocks, use thecreateInputDatasetfunction to create aDatasetobject that contains elements corresponding to root-levelInportblocks.

Inport Blocks in a Subsystem

Inportblocks in a subsystem represent inputs to the subsystem. A signal arriving at an input port on aSubsystemblock flows out of the associatedInportblock in that subsystem. TheInportblock associated with an input port on aSubsystemblock is the block whosePort numberparameter matches the relative position of the input port on the Subsystem block. For example, theInportblock whosePort numberparameter is1gets its signal from the block connected to the topmost port on theSubsystemblock.

If you renumber thePort numberof anInportblock, the block becomes connected to a different input port. The block continues to receive its signal from the same block outside the subsystem.

Inport blocks inside a subsystem supportsignal label propagation, but root-level Inport blocks do not.

你可以directly edit port labels on aSubsystemblock. For more information, seeEdit Port Labels on Subsystems

Tip

For models that include buses composed of many bus elements, consider usingIn Bus ElementandOut Bus Elementblocks. 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 aBus SelectorandGotoblock configuration.

TheIn Bus Elementblock is of block typeInportand theOut Bus Elementblock is of block typeOutport

Creating DuplicateInportBlocks

You can create any number of duplicates of anInportblock. The duplicates are graphical representations of the original intended to simplify block diagrams by eliminating unnecessary lines. The duplicate has the same port number, properties, and output as the original.

To create a duplicate of anInportblock:

  1. In the block diagram, select the unconnectedInportblock that you want to duplicate.

  2. Press and hold theCtrlkey and drag the block.

  3. Release the mouse and then selectDuplicatefrom the context menu.

You can select anInportblock that has duplicates to highlight the duplicate blocks. To show a related block in an open diagram or new tab, pause on the ellipsis that appears after selection. Then, selectRelated BlocksRelated Blocks buttonfrom the action bar. When multiple blocks correspond to the selected block, a list of related blocks opens. You can filter the list of related blocks by entering a search term in the text box. After you select a related block from the list, window focus goes to the open diagram or new tab that shows the related block.

Connecting Buses to Root-LevelInportBlocks

If you want a root-levelInportblock of a model to produce a bus, set theData typeparameter to the name of a bus object that defines the bus that theInportblock produces. For more information, seeSpecify Bus Properties with Simulink.Bus Object Data Types

Ports

Output

expand all

Input signal that flows through the inport into the system.

You can use a subsystem inport to supply fixed-point data in a structure or any other format.

Data Types:single|double|half|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 parentSubsystemorModelblock.

  • 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 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'

Select to specify the block outputs the value of the input signal at the previous time step.

Selecting this check box enables Simulink to resolve data dependencies among triggered subsystems that are part of a loop.

The Inport block indicates that this option is selected by displaying

Dependency

Enabled in a triggered subsystem.

Programmatic Use

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

选择指定块门闩t的值he input to this subsystem and prevents this value from changing during the execution of the subsystem. For a single function call that is branched to invoke multiple function-call subsystems, this option breaks a loop formed by a signal fed back from one of these function-call subsystems into the other. This option prevents any change to the values of a feedback signal from a function-call subsystem that is invoked during the execution of this subsystem.

The Inport block indicates that this option is selected by displaying

  • Dependency

    Enabled whenInportblock is in a function-call subsystem.

    Programmatic Use

    Block Parameter:LatchInputFor FeedbackSignals
    Type:character vector
    Values:'on' | 'off'
    Default:'off'
  • When loading data from the workspace to a root-levelInportblock, specify whether the block linearly interpolates and extrapolates output at time steps for which no corresponding data exists.

    To load discrete signal data from the workspace, in theInportblock dialog box:

    1. Set theSample timeparameter to a discrete value, such as 2.

    2. Clear theInterpolate dataparameter.

    Specifying the discrete sample time causes the simulation to have hit times exactly at those instances when the discrete data is sampled. You specify the data values, not time values.

    Turning interpolation off avoids unexpected data values at other simulation time points as a result of double precision arithmetic processing. For more information, seeLoad Data to Test a Discrete Algorithm

    Simulink uses the following interpolation and extrapolation:

    • For time steps between the first specified data point and the last specified data point — zero-order hold

    • For time steps before the first specified data point and after the last specified data point — ground value

    • For variable-size signals for time steps before the first specified data point — a NaN is logged for single or double data types and ground for other data types. For time steps after the last specified data point, uses ground values.

    Programmatic Use

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

    To import, visualize, and map signal and bus data to root-level inports, click this button. The Root Inport Mapper tool displays.

    Dependency

    This button appears only if this block is a root inport block.

    Signal Attributes

    Specify that the input signal outputs a function-call trigger signal.

    Select this option if it is necessary for a current model to accept a function-call trigger signal when referenced in the top model.

    Dependency

    Enabled in an asynchronous function call.

    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, seeSimulink.BusElement

    Simulink software uses this value to perform:

    • Simulation range checking (seeSpecify 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, seeOptimize 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, seeSimulink.BusElement

    Simulink software uses this value to perform:

    • Simulation range checking (seeSpecify 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, seeOptimize 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 asSimulink.NumericType

    Click theShow data type assistantbuttonto display theData Type Assistant, which helps you set the data type attributes. For more information, seeSpecify Data Types Using Data Type Assistant

    You can specify any of these options:

    • Inherited data type

    • Built-in Simulink data type — For example, specifysingleoruint8.SeeData Types Supported by Simulink

    • Fixed-point data type — Use thefixdtfunction. For example, specifyfixdt(1,16,0)

    • Enumerated data type — Use the name of the type preceded byEnum:.例如,指定Enum: myEnumType

    • Bus data type — Use the name of theSimulink.Busobject preceded byBus:.例如,指定Bus: myBusObject

    • Value type — Use the name of theSimulink.ValueTypeobject preceded byValueType:.例如,指定ValueType: windVelocity

    • Custom data type — Use a MATLAB®expression that specifies the type. For example, you can specify aSimulink.NumericTypeobject whoseDataTypeModeproperty is set to a value other than'Fixed-point: unspecified scaling'

    When you specify aSimulink.ValueTypeorSimulink.Busobject, the object defines more than the data type. The object also defines properties such asMin,Max, andUnit.The property values specified by theValueType对象覆盖呢?ponding property values specified by a block. For example, suppose a block setsUnittoft/s.When theData typeof the block specifies aValueTypeobject that hasm/sas its unit, the block usesm/sinstead offt/s

    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, seeUse Lock Output Data Type Setting(Fixed-Point Designer)

    Programmatic Use

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

    Specify whether the output for a top-levelInportblock used to load bus data is virtual or nonvirtual.

    • Select this parameter to specify a nonvirtual bus output.

    • Clear this parameter to specify a virtual bus output.

    Tips

    • All signals in a nonvirtual bus must have the same sample time, even if the associated bus object specifies inherited sample time for some elements. Any operation that would result in a nonvirtual bus containing signals with different sample rates generates an error. You cannot load multirate data for a nonvirtual bus. SeeModify Sample Times for Nonvirtual Busesfor details on how to pass signals with different sample rates into a referenced model as a nonvirtual bus.

      To load multirate data for a bus, clear theOutput as nonvirtual busparameter, and set theSample timeparameter to inherited (-1).

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

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

    Dependency

    This parameter is only available for top-levelInportblocks withBus: selected for theData typeparameter.

    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, seeAllowed Unit Systems

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

    • If aUnit System Configurationblock exists in the component, its dialog box opens. Use that dialog box to specify allowed and disallowed unit systems for the component.

    • If aUnit System Configuration块不存在组件,该模型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'|''
    Default:'inherit'

    Specify the dimensions of the output signal for this Inport block.

    -1

    The port can load data for a signal with any dimensions. The port inherits dimensions from the connected signal.

    N

    The port can load data for a signal that is a vector of sizeN

    [R C]

    The port can load data for a matrix signal havingRrows andCcolumns.

    Programmatic Use

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

    Specify the type of signals allowed out of this port. To allow variable-size and fixed-size signals, selectInherit.To allow only variable-size signals, selectYes.To allow only fixed-size signals, selectNo

    依赖关系

    When the signal at this port is a variable-size signal, thePort dimensionsparameter 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 inTypes 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, selectauto.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