Simulation runs fine despite error (index out of bounds)

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!

Réponses (1)

Deepak Meena
Deepak Meena le 28 Fév 2021

0 votes

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 commentaires

Hi. I know my simulation is running because (a) I can see the word "Running" appear in the left lower corner of my simulink window for a split second, and (b) Simulink creates the "out" variable ("Simulink.SimulationOutput", I also did a "clear all" before running the simulation!), and (c) if I add a Scope and a non-null initial value to the integrator, I get a neat exponential curve as expected. Also, in the meantime, I've tested this on three different installations of Matlab R2020b.
Hi .
On my end (a) Added the scope block , for my model it was showing Flat line (b) There was no "out" variable in the workspace . I also Tested the model in 2019b and 2020a , I was getting the same thing.So the Issue is not with the Simulink in general. But since you are facing this , Please attach your simulink model here , so I can investigate further
Hi. Your scope block is showing a flat line? Great! That clearly shows that the model has also been successfully running on your side, doesn't it? Otherwise the scope wouldn't show any line.
(The "out" variable might not have been created if you have unchecked Configuration Parameters -> Data Import/Export -> Single simulation output and/or changed the default name for that variable. You won't get the exponential curve I mentioned if you don't change the initial condition of the integrator to a non-null value.)
I've attached my Simulink model. It includes a scope block to show the flat line.
Hi
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.
Thank you!

Connectez-vous pour commenter.

Catégories

Produits

Version

R2020b

Question posée :

le 15 Fév 2021

Commenté :

le 16 Mar 2021

Community Treasure Hunt

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

Start Hunting!

Translated by