How can I add an Enumerate Entry to Data Dictionary using Matlab code

I want to add Enumerate Entries to the Data Dictionary using matlab code and based on the data that i extracted from Excel file, the problem is when i try to add an Entry, by default it takes a Matlab Variable how can i set it like Enumerate and when checking the Data Dictionary i should find my Entry as Enumerate with the values.

 採用された回答

Mohamed
Mohamed 2023 年 3 月 21 日

2 投票

Here is the answer for whos may need the same help :
MyDicObj = Simulink.data.dictionary.open('myDictionaryEnumTest.sldd');
mySection=getSection(MyDicObj,'Design Data');
%% Add an enumerated variableType to a section of a Data Dictionary
MyEnum=Simulink.data.dictionary.EnumTypeDefinition();
appendEnumeral(MyEnum,'NONE',1,'');
appendEnumeral(MyEnum,'LOCK',2,'');
appendEnumeral(MyEnum,'UNLOCK',3,'');
removeEnumeral(MyEnume,1); %To remove the default element 'enum 1', but it doesn't work with me
addEntry(mySection,'MyEnume',MyEnume);
% for more information here is the documentation :
https://ch.mathworks.com/help/simulink/slref/simulink.data.dictionary.enumtypedefinition.html?s_tid=srchtitle_Simulink.data.dictionary.EnumTypeDefinition_1

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeManage Design Data についてさらに検索

製品

リリース

R2022a

質問済み:

2023 年 3 月 17 日

回答済み:

2023 年 3 月 21 日

Community Treasure Hunt

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

Start Hunting!

Translated by