0
votes

I just discovered a bad bug because I trusted Simulink too much to care about all dependencies when using Rapid Accelerator.

Basically I have hundreds of iterations running over the same model but with different input data (coming from MATLAB workspace over "From Workspace").

Simulink seems to ignore dependencies on input data and won't rebuild the target accordingly for fresh input data.

Now I can force a rebuild for every iteration but this is not the point of an optimized model ...

How can I tell Simulink to just compile a single file containg the input + linker (which is build every iteration) rather than building the whole model?

Even if this does not work: How do I force a rebuild in the first place?

Neither

 Simulink.BlockDiagram.buildRapidAcceleratorTarget('my_model');

more setting "Rebuild all (including libraries)" in the Simulation Target settings seems to force a rebuild ....

1

1 Answers

0
votes

This is not a bug, it's a well documented fact.

When a model containing a "From Workspace" block is compiled into a Rapid Accelerator target, the standalone executable will contain all relevant variables in the workspace, with sizes and values equal to the ones they have at compilation time.

This is a good enough reason to avoid blocks like "From Workspace" by default, except in quick-n-dirty normal mode simulations.

It is kind of obvious if you think about it -- consider what would happen if your model uses a variable in the workspace

myVar = [1 2 3];

during its first run, but at the next run you set

myVar = [1 2 3 4 5 6 7 8 9 10];

This kind of flexibility is trivial in the MATLAB/Simulink environment, but implementing it in a language like C or C++ is much harder. Although generating this flexibility into the Rapid Acceleration target is possible, I wouldn't recommend it.

A much better approach is to use inports to your model, or even better, model parameters. These are elaborated for example, in this blog post, and various other places.