Simulink slower to compile when 'SrcWorkspace' set to 'current' (call to sim a function)
3 views (last 30 days)
Show older comments
Arthur Roué
on 16 Jul 2020
Commented: Fangjun Jiang
on 16 Jul 2020
I received a rather heavy model (.slx ~57Mo, 40k parameters and signals) from a client, and I need to run it several times for test purposes. To run the model, I call a function (e.g. runTest()) that load every parameters and signals and then call sim function. Here is the problem :
When the sim function is called with option SrcWorkspace set to current (i.e. runTest() workspace), the model is stuck at step "Compiling : Evaluating block parameter." for a very long time (hours scale)
However, when I assign all variables in base workspace and I call sim with SrcWorkspace set to base, this step take a reasonable amount of time (minutes scale).
Do you have any idea why calling sim within function workspace slow down the compilation step ?
0 Comments
Accepted Answer
Fangjun Jiang
on 16 Jul 2020
Do you have an apple-to-apple fair comparison? Might it be that when you specify 'SrcWorkspace' as 'current' in runTest(), the data is also loaded in base workspace thus reduces the availability of memory?
Put a breakpoint in runTest() and run "memory" in Command Window to compare.
The default SrcWorkspace for a Simulink model is base, speifying function workspace might slow down a little bit but should not be that significant.
The Simulink model itself is always loaded into the memory used by MATLAB, even though you run load_system() inside runTest().
Another alternative is to use Simulink Data Dictionary or Simulink Model Workspace to store the data.
2 Comments
Fangjun Jiang
on 16 Jul 2020
Contact Mathworks tech support if you have to use "current" workspace. It sounds like a bug or a significant performance issue.
More Answers (0)
See Also
Categories
Find more on Configure and View Diagnostics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!