i have a problem on Enumerations data type

3 visualizaciones (últimos 30 días)
elmehdi
elmehdi el 26 de Ag. de 2022
Respondida: Yash el 31 de En. de 2025
how to create a script that changes the name of enumeration variables in an sldd file

Respuestas (1)

Yash
Yash el 31 de En. de 2025
Hi,
There could be multiple methods for this, but I think it is good to use a "Simulink.data.DataConnection" object.
Refer to the example below:
% create the DataConnection object
conn = Simulink.data.connect('ddName.sldd');
% To rename, use the rename API
conn.rename('E','E1');
% If you want to change the value (or rename the enumerals)
% First get the value of the current Enum, then edit it and the set it
% Get the value
enumVal = conn.get('E1');
% Append/Remove enumerals
enumVal.removeEnumeral(1);
enumVal.appendEnumeral('Choice0',0);
% Set the Value
conn.set('E1',enumVal);
% save the changes
conn.saveChanges;
Refer to the following documentation for more details on DataConnection objects: https://www.mathworks.com/help/simulink/slref/simulink.data.dataconnection.html
The following documentation will help you to get more details on the SLDD Enumerations: https://www.mathworks.com/help/simulink/slref/simulink.data.dictionary.enumtypedefinition.html
Hope this helps!

Categorías

Más información sobre Downloads en Help Center y File Exchange.

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by