Hey Sania,
I understand that you wish to use dynamic arrays with Data Store Memory block.
As a workaround, you can preallocate memory for the arrays that you are using and modify your MATLAB function accordingly. For instance, refer to the following Simulink model:
I have initialized the Data Store Memory with an array of size 1x10 by defining it in MATLAB workspace as follows:
I have written a simple MATLAB function which takes in the array and with each time step/iteration, it modifies the array. In this scenario, I am using the defined array as a stack, where the first element stores the position for the top of the stack and I make the modifications accordingly. You can refer to the following code snippet for implementing the MATLAB Function block:
In this way you can emulate your pre-allocated arrays to work as dynamic ones as per our need. Here is a screenshot of one of the time step of the simulation, showing how the array would grow:
Once the Simulation is complete, you can extract the desired array by simply removing the first element. If you wish, then for each of these arrays, you can maintain a separate variable to keep track of the number of elements currently present in the array.
If you have multiple such variables then the best way would be to create helper functions for handling the growing arrays.
I hope this was helpful!