Run-time parameterization of discrete sample time in generated code?

1 view (last 30 days)
I have created an atomic sub-system that I want to generate code from (C++ interface), which will be used in various places in our code base. The block will be executed in discrete-time using one single sample time. The thing is that I would like to parameterize the generated code with the sample-time at the time of instantiation of the C++ class, prior to execution. I have added a parameter "sampleTime" to the block but the code generator hard codes the value of the sample time that was currently present at the time of code generation. This is a problem for blocks that make use of the sample-time in their calculations, for example the "Rate limiter" block. Note that it is only needed to set the sample-time once at start (before stepping), and it is not needed to change it during execution.
  2 Comments
TAB
TAB on 7 Apr 2015
What "Storage class" you are using for parameter "sampleTime" ? Is it "Auto" ?
Pontus Bergsten
Pontus Bergsten on 7 Apr 2015
Edited: Pontus Bergsten on 7 Apr 2015
I have tried the various storage classes that are available in the "Pick tunable parameters"-list, but it doesn't matter which option I select.

Sign in to comment.

Answers (0)

Categories

Find more on Simulink Coder 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!