Error overwriting array when using Simulink
The following error I get when running the model:
An error occurred while running the simulation and the simulation was terminated
Caused by: Size mismatch for MATLAB expression ‘array’. Expected = 1×100 Actual = 1×1
The model includes two functions: (1) adding and (2) deleting elements from the array in a base workspace. Fixed-step solver is set for the model, so a new elements is added (or an existing element is removed) each tick.
Then, both functions use a class with the following methods: declare the array, add/delete an element, refresh the array. In the functions I use a persistent variable for the class.
The functions and class work properly via Command Window. But that error occurs if the functions call from the Simulink model. It happens when the array refresh method is used.
Instead of using the array refresh method, I tried to use a global variable. It also works to me via the Command Window, however other errors happen to Simulink:
Global declaration not resolved to a Data Store Memory block registered via the Ports and Data Manager.The following error I get when running the model:
An error occurred while running the simulation and the simulation was terminated
Caused by: Size mismatch for MATLAB expression ‘array’. Expected = 1×100 Actual = 1×1
The model includes two functions: (1) adding and (2) deleting elements from the array in a base workspace. Fixed-step solver is set for the model, so a new elements is added (or an existing element is removed) each tick.
Then, both functions use a class with the following methods: declare the array, add/delete an element, refresh the array. In the functions I use a persistent variable for the class.
The functions and class work properly via Command Window. But that error occurs if the functions call from the Simulink model. It happens when the array refresh method is used.
Instead of using the array refresh method, I tried to use a global variable. It also works to me via the Command Window, however other errors happen to Simulink:
Global declaration not resolved to a Data Store Memory block registered via the Ports and Data Manager. The following error I get when running the model:
An error occurred while running the simulation and the simulation was terminated
Caused by: Size mismatch for MATLAB expression ‘array’. Expected = 1×100 Actual = 1×1
The model includes two functions: (1) adding and (2) deleting elements from the array in a base workspace. Fixed-step solver is set for the model, so a new elements is added (or an existing element is removed) each tick.
Then, both functions use a class with the following methods: declare the array, add/delete an element, refresh the array. In the functions I use a persistent variable for the class.
The functions and class work properly via Command Window. But that error occurs if the functions call from the Simulink model. It happens when the array refresh method is used.
Instead of using the array refresh method, I tried to use a global variable. It also works to me via the Command Window, however other errors happen to Simulink:
Global declaration not resolved to a Data Store Memory block registered via the Ports and Data Manager. array, simulink, variable, arrays, variables, class MATLAB Answers — New Questions