- Open or Create an SLDD: Open your existing SLDD or create a new one using the Simulink Data Dictionary Manager.
- Add Enum to SLDD: You can add the enumerated type to the SLDD by referencing the m-file. Here’s how you can do it programmatically:
How can I export all the enumerated data types from m-file to an SLDD (Data Dictionary)? Can Enum be created in m-file? IF yes what's the solution for this?
26 views (last 30 days)
Show older comments
Creating Enum definition in the m-file and exporting back to SLDD
0 Comments
Answers (1)
Manikanta Aditya
on 27 Dec 2024 at 14:59
Edited: Manikanta Aditya
on 29 Dec 2024 at 13:10
Yes, you can create enumerated data types (Enums) in an m-file and export them to an SLDD (Simulink Data Dictionary).
1.) Create a Enum in an m-file: Create a new m-file and define your enumeration class. For example, if you want to define days of the week, your m-file (e.g., WeekDays.m) would look like this:
classdef WeekDays
enumeration
Monday, Tuesday, Wednesday, Thursday, Friday
end
end
Refer to the following documentation to know more about enumation classes:
2.) Export Enum to SLDD:
% Load the SLDD
slddObj = Simulink.data.dictionary.open('yourDataDictionary.sldd');
% Get the section where you want to add the enum
dData = getSection(slddObj, 'Design Data');
% Add the enum type definition
addEnumType(dData, 'WeekDays', 'WeekDays.m');
Refer to the following documentation to know more about 'addEnumType':
3.) Save and Close the SLDD: After adding the enum, save and close the SLDD:
saveChanges(slddObj);
close(slddObj);
I hope this helps you.
2 Comments
Manikanta Aditya
ongeveer 15 uur ago
It looks like you're encountering an issue with the addEnumType function. This function was introduced in MATLAB R2023b and is used to add enumerated data types to the Architectural Data section of a Simulink data dictionary.
Please ensure that you are using MATLAB R2023b or later, as the addEnumType function is not available in earlier versions
See Also
Categories
Find more on System Composer 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!