Why is signal dimension not propagated properly when Embedded MATLAB blocks are used in a closed loop in Simulink 7.3 (R2009a)?

2 views (last 30 days)
I am using two Embedded MATLAB blocks with output signals of various dimensions in Simulink 7.3 (R2009a). I have four signals defined in the first Embedded MATLAB block, of which two, Conv, of size [61x4], and thermalinlet, [1x13], are fed to the inports of the second Embedded MATLAB block. Another scalar signal called BrickTemp which is defined in the second Embedded MATLAB block is fed back to the first block. This however throws the following error in the second Embedded MATLAB block when I try to update the diagram (CTRL+D) or run it:
Index expression out of bounds. Attempted to access element 2. The valid range is 1-1.
in conjunction with this warning:
Chart Reactor/Thermal #67 has signals with underspecified type, size, and/or complexity.
Choosing values for the underspecified properties by internal rule.
To avoid this warning and subsequent errors caused by incorrect choices you can either specify the signal properties more fully elsewhere in your model or set these properties explicitly.
If I break the loop, the error goes away.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 25 Feb 2015
In general, signal dimension propagation starts from the source block, and uses the block connectivity and internal rules of the block to propose dimensions to each port. When Simulink encounters a loop, it needs to determine the starting location to start propagating the dimension of each signal based on heuristics. Sometimes, it is necessary to do this iteratively until all dimensions are defined.
The best scenario is to break the loop and provide Simulink somewhere to start, by inserting a Signal Specification block. For example, place a Signal Specification block in the feedback line of BrickTemp.
Another way to help Simulink propagate signal dimensions properly is to explicitly define the sizes inside the blocks. For example, double-click on the first Embedded MATLAB block to open the block's code in the Embedded MATLAB Editor, click on 'Edit Data/Ports', and specify the size of Conv to be [61 4] and the size of thermalinlet to be [1 13].

More Answers (0)

Products


Release

R2009a

Community Treasure Hunt

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

Start Hunting!