Define global variables for MATLAB function usage within Simulink for Embedded Code
3 views (last 30 days)
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
Thanks for help.