m_power
m_power

Reputation: 3204

How to avoid using the To Workspace block

I ran the profiler on my Simulink model and realized that the "To Workspace" block is using 20% of the total simulation time. Because this model is ran more than one time, I'm looking for a way to increase its performance.

Hence, is there an alternate solution to using the "To Workspace" block that would increase my model global performance?

Upvotes: 1

Views: 665

Answers (2)

birincilikteli
birincilikteli

Reputation: 83

According to my general understanding of memory management, reserving a fixed memory block takes less time than expanding it in each timestep. So, it might be useful to limit the number of data points to be logged, that the memory space reserved for your data set will not be dynamically increased at every timestep. Of course this would be only valid if you would know the number of data points and therefore number of steps in simulation prior to start of the simulation, which can be achieved by a fixed step size solver (if applicable by your simulation system setuo). Thus pre-allocation of the workspace array might save you some time in terms of not reaching the memory management system at each timestep.

Upvotes: 0

am304
am304

Reputation: 13886

Yes, you can use Signal Logging. The various approaches to logging simulation results are discussed in the documentation under Export Simulation Data. Finally, see also View Simulation Results for alternative approaches. My personal recommendation would be signal logging or a To File block.

Upvotes: 1

Related Questions