Define global variables for MATLAB function usage within Simulink for Embedded Code
조회 수: 10 (최근 30일)
이전 댓글 표시
Hello,
I'm trying to create a global variable in my Simulink model, that will be visible within all MATLAB function blocks. I used the Simulink.Signal class with all properties defined. Inside the function, the 'global varName' is included, as well as variable is defined as Data Store Memory. The following error occurs:
Found unsupported global datainitialization class dor global variable 'varName'
Code generation does not supportimporting handle classes from MATLAB
As Simulink.Signal is handle class, I assume i can't use it to generate code from model to run in on HW.
Is there a way to define one, let's say Data Dictionary, to store all variables that I will use within all submodel of my main model and define which are global? I do not want to define them every time I create a new submodel and i want to enable visibility of variables within the MATLAB functions, without putting them as input every time (what I normally practise).
I also tried to use enum class, and that approach is visible in MATLAB functions, but sometimes there is a need to define two parameters of the same value (I would like to use structures instead of enums). Next problem occurs while using same 'Multiplier' field in 2 enums with different names. Simulink cannot generate code while using this approach.
classdef CurrentProtectionThresholds < int16
enumeration
Multiplier (100)
DischargeWarningThr (-1000)
DischargeErrorThr (-1200)
ChargeWarningThr (250)
ChargeErrorThr (300)
ImmunityLow (-50)
ImmunityHigh (50)
end
end
Thanks for help.
댓글 수: 0
답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Naming Conventions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!