- The structure of the Simulink Model is straightforward. It consists of ‘Data Store Memory’ block named ‘MyMatrixDataStore’, a subsystem and a ‘Display’ Block.
- In edit mask section, a spin box parameter is created to select a value between 1 and 10. This value is stored under the name ‘nValue’. Additionally, a callback is associated with this parameter to create ‘myMatrix’ and store it in the base workspace.
- The ‘Data Store Memory’ block's initial value is set to ‘myMatrix’, enabling it to read ‘myMatrix’ from the base workspace and then provide it as input to the ‘MATLAB function’ block through the ‘Data Store Read’ block.
- The subsystem utilizes the ‘Data Store Read’ block to feed ‘myMatrix’ into the ‘MATLAB function’ block. It is important to name the ‘Data Store Read’ block the same as the ‘Data Store Memory’ block, to access data across workspaces.
- The ‘MATLAB function’ block is designed to take ‘myMatrix’ as input and output the sum of the elements of the matrix.
- ‘get_param’: https://www.mathworks.com/help/releases/R2021a/simulink/slref/get_param.html .
- ‘assignin’: https://www.mathworks.com/help/releases/R2021a/matlab/ref/assignin.html .
- ‘Data Store Memory’: https://www.mathworks.com/help/releases/R2021a/simulink/slref/datastorememory.html .
- ‘Data Store Read’: https://www.mathworks.com/help/releases/R2021a/simulink/slref/datastoreread.html .