Unbounded Variable-Size Signal Basic Operations - MATLAB & Simulink (original) (raw)

Main Content

This example shows how to use unbounded variable-size signals in Simulink® modeling. For more information about the general concept of unbounded variable-size signals, see Unbounded Variable-Size Signals.

This model describes how to configure blocks to use unbounded variable-size signals.

open_system('ex_boundedsignals')

To display the signal dimensions, in the Simulink Editor, on the Debug tab, select Information Overlays and click Signal Dimensions.

Model with blocks that use signals with finite size.

The following sections describe how to configure the Inport block, MATLAB Function block, MATLAB System block, Simulink Signal object and Simulink Bus object to use unbounded variable-size signals.

Configure Inport Block to Generate Unbounded Variable-Size Signals

In the block dialog box:

The Inport1 block connected to the input port of the Selector block is configured to generate an unbounded variable-size signal with dimension [Inf 6], data type uint16, and sample time 1. You can configure all the other Inport blocks similarly to generate unbounded variable-size signals. In this example, configure both the Inport2 block and Inport3 block to generate unbounded variable-size signals with sample time 1 and dimensions [Inf 6].

The block parameters dialog box shows signal attributes for the unbounded variable-size signals.

The block parameters dialog box shows execution settings for the unbounded variable-size signals.

To use an unbounded variable-size signal as index signal to the Selector block, replace the Constant block with an Inport block. Configure the Inport block to generate the index signal with dimension Inf, data type uint16 and sample time 1. Also, for the Selector block, in the Block Parameters dialog box, select Number of input dimensions as 2, Index Option as Index vector (dialog) as [3 4 5].

Configure MATLAB Function Block

Specify the size of a variable-size input/output signal associated with the MATLAB Function block. To interactively configure the MATLAB Function block, in the Simulink Editor, on the Modeling tab, from the Design gallery, select Model Explorer. From the Model Explorer window, select the MATLAB Function. Set the dimension in Size to [Inf 6] and select Variable size.

The Model Explorer shows settings for the MATLAB Function block that is configured to support unbounded variable-size signals

Configure MATLAB System Block and System Objects

The MATLAB System block uses the System object® sigOps that adds and computes difference between two signals. While configuring the System Object® for unbounded variable-size signals, set the flag for isOutputFixedSizeImpl to false and change the output dimensions for getOutputSizeImpl to [Inf 6].

System Object configuration for the unbounded variable-size signals.

Specify the size of a variable-size Simulink.Signal object as unbounded. To programmatically configure the signals, in the Simulink Editor, on the Modeling tab, select Model Settings > Model Properties. In the Model Properties dialog box, on the Callbacks tab, select PreLoadFcn to edit the Simulink.Signal object properties.

For the signal object:

Simulink signal object configured to support unbounded variable-size signals

Specify the size of a variable-size Simulink.Bus object as unbounded. To programmatically configure the bus elements, in the Simulink Editor, on the Modeling tab, select Model Settings > Model Properties. In the Model Properties dialog, on the Callbacks tab, select PreLoadFcn to edit the Simulink.BusElement object properties.

For each bus element:

Simulink Bus Elements configured to support unbounded variable-size signals.

Configure Data Store for Unbounded Variable-Size Signals

To Configure the Data Store Memory block to store bus object A, in the Data Store Memory dialog box, on the Signal Attributes tab, set Data type to Bus:A.

Compile the Model and Verify Signal Dimensions

Once you configure the blocks and Simulink objects, update (Ctrl+D) the model. Save (Ctrl+S) the model in the working folder and close it. Re-open the model for the updated properties of Simulink.BusElement and Simulink.Signal objects to be effective.

To verify if the model components are properly configured to support unbounded variable-size signals, check the signal dimensions. To display the signal dimensions, in the Simulink Editor, on the Debug tab, click Information Overlays and select Signal Dimensions.

Model with blocks that use unbounded variable-size signals.

Set Model Configuration Parameters for Simulation

In the Simulink Editor, on the Modeling tab, select Model Settings. In the Configuration Parameters dialog box:

Set Up Data Logging

To log the output signals from the Data Store Read block, use the Outport block. In this case, the output signals sig1 and sig3 are Simulink bus elements.

See Also

Selector | MATLAB Function | MATLAB System | Bus Creator | Bus Selector | Inport

Topics