MATLAB Answers

Simulation runs fine despite error (index out of bounds)

1 ビュー (過去 30 日間)
creepydog
creepydog 2021 年 2 月 15 日
コメント済み: creepydog 2021 年 3 月 16 日
Hello.
Summary
For my simple model, Simulink (R2020b) throws an error during Model Update, but afterwards allows me to simulate (run) the model without any problems. In my understanding, an error during Model Update should make the Model Update unsuccessful and prevent me from running the simulation. The error does not occur using R2018b and R2019b. I wonder whether this is a bug.
Steps to reproduce
Create an empty model. Insert and connect the following blocks as shown in the screenshot: Integrator, MATLAB Function, Mux, Demux, Terminator. Change the code for the MATLAB Function as shown in the screenshot. Activate "Signal Dimensions" and "Non-scalar lines" in Debug --> Information Overlays --> Signals. Do not change any other default settings.
During Model Update, Simulink (R2020b) shows this error message:
The error messages argues that accessing x(2) is invalid. Despite the error, Simulink has identified the correct signal dimensions (see block diagram) and allows running a simulation without any problems.
Remarks
That is a minimal example I found to demonstrate the problem. It does not do anything useful. I know I can suppress the error by specifying the dimension ("2") of one of the ports of "fcn" or by using a Signal Specification block on either of the non-scalar signal lines. No need to tell me that. That's not my question. If Simulink finds an error, it should stop me. And if there's no problem, Simulink shouldn't throw an error. And I wonder why the behavior changed somewhere between R2019b and R2020b.
Thanks for your help!

回答 (1 件)

Deepak Meena
Deepak Meena 2021 年 2 月 28 日
Hi ,
I also run the example you described, I am also getting the error you described but my simulation is not running after the error , let me know how do you know ,your simulation is working after the Error.
  5 件のコメント
creepydog
creepydog 2021 年 3 月 16 日
Thank you!

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by