0

I'm developing a Simulink model with many constants.

I'm trying to:

  • Avoid hardcoding every constant in the model and have something unreadable.
  • Be able to know what that 9.73288483... constant in the middle of my model stands for.

I wanted to add all my constants to a header file to have them as global constants (/including the header file everywhere) so that I could directly refer to their name instead of the value and it would also simplify my model.

Another reason for me to use a header file is that I will then generate my model in C using Simulink coder, and I really want to have that header file to have a clean generated code

I've seen people in here referring to the existence of such function. So I've been wondering if anyone here could help me out?

Then I could also apply it to replace my functions parameters by global constants in another header file which would let me simply load a different "parameters_values.h" file when I want to change the conditions of my simulation easily.

Wolfie
  • 27,562
  • 7
  • 28
  • 55
Hood
  • 63
  • 1
  • 7
  • Have you looked at `FromWorkspace` blocks, and running your simulation from a script which initialises constants in your workspace? – Wolfie Feb 07 '20 at 15:07
  • My first idea was doing my own script to initialise those, i know how i would do that, but if i can just include a header file and include it it would be much easier, even more so when i have to generate the code, which is why i am asking this question. I did not check "FromWorkspace", i will right now and see what it does – Hood Feb 07 '20 at 15:40

1 Answers1

0

You can specify under "file->model properties" callback functions

Batman
  • 1
  • 1