When export simlink model to FMU by matlab2023b, cannot export the paraments set in InitFcn,how to deal it
Show older comments


The following parameters are not exported due to Code Generation limitations: 'Branch_L,Cap_Value,Initial_Voltage_Cap,Load_R,Ts,end_time,start_time'. Update the storage class of the parameter to get the expected results.
组件:Simulink | 类别:Model 警告
Answers (1)
Nithin
on 24 Apr 2025
0 votes
This error occurs because parameters defined in the "InitFcn" (Initialization Function) are not automatically recognized as "tunable" or "exportable" during FMU code generation. By default, these parameters are treated as constants or local variables, so they are not included as FMU parameters.
To address this, you can make these parameters tunable in the FMU by creating them as "Simulink.Parameter" objects in the MATLAB base workspace and setting their "StorageClass" to "ExportedGlobal" or "Model default".
If this approach does not suit your needs, you can try one of the following alternatives:
- Define the parameters as "Simulink.Parameter" objects directly in the model workspace and set their "StorageClass" to "ExportedGlobal".
- Convert the model to use a data dictionary, store all the parameters in the dictionary and set the storage class as needed.
Kindly refer to the following MathWorks documentations for better understanding about:
- Simulink.Parameter: https://www.mathworks.com/help/simulink/slref/simulink.parameter.html
- Data dictionary: https://www.mathworks.com/help/simulink/ug/what-is-a-data-dictionary.html
Categories
Find more on FMU Importing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!