Simulink Custom Storage Class "Importeddefine"

12 visualizaciones (últimos 30 días)
Andreas
Andreas el 28 de En. de 2011
I have a headerfile (params.h) with some defines (#define test_param 22) and want to use/import this in a Simulink model (ERTW). I add a Simulink.Parameter and assign "ImportedDefine (Custom)" as Storage Class and add "params.h" to the "Custom attributes -> Header file". How can I use this "test_param" in the model (it does not work with a constant / gain block) ?
  2 comentarios
Kaustubha Govind
Kaustubha Govind el 28 de En. de 2011
Hi Andreas,
Do you see an error when you use the parameter with a gain block? Could you post the error?
~K
Andreas
Andreas el 31 de En. de 2011
I named the Simulink.Parameter "test_param" and put this string in the field "gain" of the gain block. If I assign no value to "test_param" I get the error "Invalid setting in 'mymodel/Gain' for parameter 'Gain'". If I assign a value to "test_param" the model uses this value (without an error) but does not import the value from the #define in the specified header file.
Also same behaviour with a constant block.

Iniciar sesión para comentar.

Respuestas (1)

MarkB
MarkB el 31 de En. de 2011
Basically, Simulink itself doesn't use header files, but compilers do. Thus, in this case the "Simulink.Parameter"'s job is essentially to describe the content of the header file for simulation. As a result, the ".Value" field that you use in your "Simulink.Parameter" object is the number that Simulink will use when you press the "play" button.
However, when you generate code, the data object will cause a "#include" statement to appear in the generated code, and the code will use (but not define or declare) the name "test_param", expecting the header file provide it.
Since the "Simulink.Parameter" is what is used for simulation, it is important to ensure that it accurately reflects what the header file will provide to the generated code (i.e. the numeric values should match).

Categorías

Más información sobre Simulink Functions en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by