MATLAB Answers

Global Simulink static/constant inside Matlab function

19 views (last 30 days)
amin ya
amin ya on 10 Mar 2020
Answered: Mark McBroom on 22 Mar 2020
Is there a way to define a global Simulink constant that can be called from Matlab functions?
I know these options but none work:
  • Datastore block doesn't have an option for being set to constant
  • Global variables (like in C) are not function's argument so using function input isn't what I want. But fine if there is no other way
  • I cannot set function parameters to constant.
I want to make the code efficient instead of reading from memory for each time step. Compilers usually hard code the static constants automatically, but Simulink doesn't have an option for this.

  0 Comments

Sign in to comment.

Answers (1)

Mark McBroom
Mark McBroom on 22 Mar 2020
If you add an argument to your MATLAB function and mark it as a parameter. Simulink will then look for this parameter in the MATLAB workspace.

  0 Comments

Sign in to comment.