Can you explain the different dialog options and behavior of the MERGE and the OUTPORT blocks when used together?

1 view (last 30 days)
I have a model with an IF-ELSE construct whose outputs are sent to a MERGE block. However, I am not sure about the outputs that I receive when I change the following block parameters:
OUTPORT: Output when disabled
MERGE: Allow unequal port width
Also, if I put a GAIN block between the If Action Subsystem and the MERGE block, the output of the MERGE block seems to change.
Please see attached model.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 15 Jun 2018
Here is some information about the MERGE block and the OUTPORT block inside conditionally executed subsystems. Please see the attached model for reference.
A) OUTPORT: Output when disabled: Held
MERGE: Allow unequal port width: Unchecked
- All the inputs to the MERGE block can be considered to be writing to the same physical memory location. Hence, whatever is written last to the memory location will go the output of the MERGE block.
- If no initial conditions are specified for the MERGE block, then the MERGE block will pick up the initial condition (if specified) of the input signal coming from the block with the highest sorted order (see Format > Block Displays > Sorted Order)
B) OUTPORT: Output when disabled: Held
MERGE: Allow unequal port width: Checked
Input port offsets: Specified
The offset parameter is used for writing the inputs to the MERGE into different ranges of a vector. When using this option, the two inputs are usually expected to be of different sizes. For example: If Input1 is of width 5 and Input2 is of width 3, and you want the output to be a width of 5, you can apply an offset for Input2 to put the values into
offset 0: index 1,2,3
offset 1: index 2,3,4
offset 2: index 3,4,5 of the output signal
A higher offset will result in the output signal being more than 5 elements.
C) OUTPORT: Output when disabled: Reset
We do not recommend using this option when working with MERGE block since it may lead to unexpected results.
D) Connecting blocks between output of conditionally executed subsystem and input of MERGE block:
The inputs to the MERGE block should come directly from a conditionally executed subsystem. There should not be any blocks in between. For example, if a GAIN (=1) block is put in the path, then since the GAIN block executes at every time step, the output of the MERGE block may get held to the output of the last GAIN block in the sorted order (see (A) above)
E) Where possible, use the If or Switch Case block to provide control logic and avoid Enabled Subsystems.
Here are the guidelines for using MERGE blocks which have been taken from the documentation section 'Merge : Guidelines for Using Merge Block.
- Do not connect an input of a Merge block to any other block. Doing so causes an error.
- Always use conditionally executed subsystems to drive Merge blocks.
- Always set the Initial output parameter of the Merge block.
- Where possible, use the If or Switch Case block to provide control logic.
- Write your control logic to ensure that at most one of the driving conditionally executed subsystems executes at any time step.
- For all conditionally executed subsystem Outport blocks that drive Merge blocks:
o Set the Initial output parameter to empty matrix ([]).
o Set the Output when disabled parameter to held.
Please see the Merge Block's documentation:
for more information.

More Answers (0)

Categories

Find more on Component-Based Modeling in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!