Using Simulink Enumerations from Workspace without Data Dictionary in order to Protect a Simulink Model

Hello,
I have a Simulink model I want to protect. The model uses a data dictionary, and I am copying all data to the base workspace and then delete the data dictionary. Simulink bus and parameters work fine, but the Enums do not. The model uses Simulink Enumerations. When copying them into base workspace, the Simulink model cannot evaluate them. I tried to create a class p-code file, but this still did not solve the problem.
Does anyone have any idea how can I solve this? I want to be able to protect the model, hiding all its used data?
Thanks ahead!
P.S. Reconstructing the model to not use the Enum will not work as there many used instances, especially in stateflows

Réponses (1)

Soumya
Soumya le 27 Mar 2026
Modifié(e) : Soumya le 27 Mar 2026
Hi Mohamed,
I understand that you are trying to protect your Simulink model by copying all data from the data dictionary to the base workspace, but Simulink enumerations are not working while parameters and bus objects do. This behavior is expected because in Simulink, enumerations are implemented as MATLAB class definitions (classdef) rather than simple workspace variables. As a result, copying them into the base workspace does not recreate the class, and both Simulink and Stateflow cannot resolve the enum type during model evaluation.
You can follow the steps below to resolve the issue:
  • Ensure that all enumeration definitions are maintained as class files (.m during development).
  • For protection, convert these enum classes to .p files and distribute only the protected versions.
  • Make sure the folder containing the enum class files is added to the MATLAB path before running the model.
  • Avoid attempting to store or reconstruct enums in the base workspace, as this is not supported.
You can refer to the following documentation for more information:
I hope this helps!

Catégories

Produits

Version

R2021a

Modifié(e) :

le 27 Mar 2026

Community Treasure Hunt

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

Start Hunting!

Translated by