Yesterday, while researching another data extraction issue, I stumbled over the following command:
I managed to achieve the desired result, by using the same approach as you suggested @Suraj Kumar, but using the createMATLABStruct command instead of your step 2. So, one of my Simulink.Parameter objects is created like this:
TempStruct = Simulink.Bus.createMATLABStruct('UDT_Parameter',[],1,dictionaryObj); % Create struct from nested bus in Data Dictionary
Parameter = Simulink.Parameter;
Parameter.Value = TempStruct;
Parameter.CoderInfo.StorageClass = 'ExportedGlobal'; % Setting for PLC Coder
Parameter.DataType = 'Bus: UDT_Parameter';
setValue(getEntry(sectionObj,'Parameter'), Parameter); % Write object in DD
This morning, I test your step 2:
myStructData = getValue(getEntry(dData, 'myStructData'));
and that didn't work out of the box, as myStructData is a Simulink.Bus. I received this error message:
Invalid value specified for parameter. Value must be a numeric array, fi object, enumerated value, structure whose fields
contain valid values, string scalar, or an expression.
So that must be converted to at struct to work. But createMATLABStruct works as a one line command, so I'll stick to that.