Clear Filters
Clear Filters

Simulation runs fine despite error (index out of bounds)

1 view (last 30 days)
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.
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!

Answers (1)

Deepak Meena
Deepak Meena on 28 Feb 2021
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.
Deepak Meena
Deepak Meena on 16 Mar 2021
It seems like a bug to me as well , I have reported the issue and I will let you know once I got responce from them.

Sign in to comment.


Find more on Event Functions in Help Center and File Exchange




Community Treasure Hunt

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

Start Hunting!