MATLAB Answers

How to make Simulink.Parameter parameters stored in model workspace tunable?

조회 수: 10(최근 30일)
Sean
Sean 29 Oct 2018
답변: Nick Sarnie 3 Nov 2018
I'm using Embedded Coder to generate C++ code, in r2016b. The documentation (e.g. link ) says I can make a Simulink.Parameter parameter tunable simply by changing Storage Class to SimulinkGlobal (I want tunable parameters to show up in the generated code as elements of a parameters struct).
However, I find that when the parameter is stored in the Model Workspace, the generated code does not contain a tunable parameter, yet if that same parameter is stored in the Base Workspace, the code generator does what I expect it to do and generates a tunable parameter. After skimming many pages of documentation I haven't found any mention of a limitation here though.
I'm able to reproduce this issue in the built-in demo exercise "rtwdemo_paraminline" ( link ) - when the gain parameter is stored in the Model Workspace, the resulting code has the parameter inlined (not tunable), but when stored in base workspace the generated code has it tunable.

  댓글 수: 0

댓글을 달려면 로그인하십시오.

채택된 답변

Nick Sarnie
Nick Sarnie 3 Nov 2018
Hi Sean,
This is a limitation of R2016b. In the R2016b doc for Simulink.Parameter , you will notice the following line under Storage Class:
If you store the parameter object in a model workspace, the code generator ignores this property.
I tried this out in R2018b and everything worked as expected.
Thanks, Nick

  댓글 수: 0

댓글을 달려면 로그인하십시오.

추가 답변(0개)

제품


릴리스

R2016b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by