Why is MATLAB/Simulink function call creating duplicated / cloned parameters?

1 visualización (últimos 30 días)
I have a MATLAB/Simulink software which is converted to C code, to be applied as an embedded application.
Inside this Simulink model I have a few stateflow with function call charts. These subsystems refer to some base workspace parameters to do their calculations, as follows:
Whenever I try to simulate this model, stimulating the inputs and reading the outputs, I get the following 'glitch' - the workspace defined variable 'multiplies', and the model simulation crashes because these new parameters have no defined values:
If I try to run the model again, more clones are created (4, 5 ,6 ...).
Do anyone has any clue on this?
Thanks!

Respuestas (1)

Karan Singh
Karan Singh el 29 de Sept. de 2023
Hi Matheus,
From what I understand, a MATLAB-Simulink model has been converted to C code for deployment as an embedded application and within this Simulink model, there are Stateflow charts that make use of parameters from the base workspace to perform calculations. While during the simulation of the model, when providing inputs and reading outputs, leads to creation of multiple clones and errors.
The issue you're facing seems to be related to the usage of base workspace parameters in your Simulink model, specifically within the Stateflow charts. When the model is converted to C code and deployed as an embedded application, the base workspace is not available, leading to undefined values for the parameters.
To address this issue, you can consider the following approaches:
  1. Local Parameterization: Instead of relying on base workspace parameters, you can parameterize the Stateflow charts locally within the charts themselves. By doing so, the parameters will be accessible within the Stateflow charts even without the base workspace.
  2. Model Workspace: Simulink provides a model workspace that can be used to define model-specific parameters. These parameters can be accessed by the Stateflow charts and other components within the model. To define parameters in the model workspace, go to the Simulink Editor, click on the "Modeling" tab, and select "Model Settings." In the "Model Settings" dialog, navigate to the "Model Properties" tab and click on "Model Workspace" to define the necessary parameters.
  3. Input Ports: Instead of relying on base workspace parameters, you can pass the required parameters as input signals to the Stateflow charts. By connecting the input ports of the charts to the corresponding parameters, you ensure that the necessary values are provided during simulation or deployment.
Attached below are some documentation links that you may find helpful:
Hope this helps!
Karan Singh Khati
  1 comentario
Matheus Sozza
Matheus Sozza el 29 de Sept. de 2023
Hi, Karan.
I solved this problem ~1year ago and to be honest I don't remember 100% what I did exactly...
What is remember is that before running my Model in The Loop environtment I had to re-lock all the libraries that were being called in my simulatable model. If I kept the referred libraries open and unlocked, this duplication occurred... Does not have a reasonable explanation (in my point of view), but seems to work this way.

Iniciar sesión para comentar.

Categorías

Más información sobre Complex Logic en Help Center y File Exchange.

Productos


Versión

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by