Global Simulink static/constant inside Matlab function

조회 수: 31 (최근 30일)
amin ya
amin ya 2020년 3월 10일
답변: Mark McBroom 2020년 3월 22일
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.

답변 (1개)

Mark McBroom
Mark McBroom 2020년 3월 22일
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.

카테고리

Help CenterFile Exchange에서 Deployment, Integration, and Supported Hardware에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by