addStructType - Add structure type to Architectural Data section of Simulink data dictionary - MATLAB (original) (raw)
Main Content
Add structure type to Architectural Data section of Simulink data dictionary
Since R2023b
Syntax
Description
[dataType](#mw%5F7d6075da-edb1-4e9b-98fa-287f20d5010a) = addStructType([archDataObj](#mw%5F1a7ca6db-e4ef-4f2e-9dd6-1327087dcc12),[dataTypeName](#mw%5F5b34761e-c4de-4688-8a7a-dabee3410785))
adds a Simulink.Bus type specified bydataTypeName
to archDataObj
, the Architectural Data section of the data dictionary.
[dataType](#mw%5F7d6075da-edb1-4e9b-98fa-287f20d5010a) = addStructType([archDataObj](#mw%5F1a7ca6db-e4ef-4f2e-9dd6-1327087dcc12),[dataTypeName](#mw%5F5b34761e-c4de-4688-8a7a-dabee3410785),SimulinkBus=[busObj](#mw%5F2389c03d-50a6-48b5-83de-05c86799cbac))
adds a structure type that is the same as the specified Simulink.Bus
object, busObj
, to the data dictionary.
Examples
To add a Simulink.Bus
type with the specified name to a data dictionary, use the addStructType
function. For an example that shows more of the workflow for related functions, see Create Architectural Data Object and Use It to Configure Architectural Data.
Create or open a data dictionary. This example uses a previously created data dictionary MyInterfaces.sldd
.
dictName = "MyInterfaces.sldd"; archDataObj = Simulink.dictionary.archdata.open(dictName);
Add a structured data type to the Architectural Data section of the data dictionary. You can specify the name, data type, and dimensions using theaddStructType
function or the object representing the structured data type.
myStructType1 = addStructType(archDataObj, "myStructType1"); structElement1 = myStructType1.addElement("Element1"); structElement1.Type.DataType = 'single'; structElement1.Type.Dimensions = '3';
This example adds a StructType
type that is the same as an existing Simulink.Bus
object to the Architectural Data section of the Simulink® data dictionary, MyInterfaces.sldd
.
Create or open a data dictionary.
dictName = "MyInterfaces.sldd"; archDataObj = Simulink.dictionary.archdata.open(dictName);
Create a Simulink.Bus
object and add elements using theSimulink.Bus
object.
simBusObj = Simulink.Bus; busElement1 = Simulink.BusElement; busElement1.Name = "MyBusElement1"; busElement1.DataType = 'single'; simBusObj.Elements(1) = busElement1; busElement2 = Simulink.BusElement; busElement2.Name = "MyBusElement2"; simBusObj.Elements(2) = busElement2;
Using the addStructType
function you can add a structured data type to the Architectural Data section of the data dictionary that is based on theSimulink.Bus
object created in the previous step.
myNewStructType = addStructType(archDataObj,"StructFromSimBus",SimulinkBus=simBusObj)
myNewStructType =
StructType with properties:
Name: 'StructFromSimBus'
Description: ''
Elements: [1×2 Simulink.dictionary.archdata.StructElement]
Owner: [1×1 Simulink.dictionary.ArchitecturalData]
Input Arguments
DataType
definition name in the DataTypes
property array of archDataObj, specified as a character vector or a string scalar.
Example: "airSpeed"
Simulink.Bus
data type object, specified as a Simulink.Bus object.
Output Arguments
Structure type object, returned as aSimulink.dictionary.archdata.StructureType
object containing structure elements, with Simulink.Bus as the underlying implementation.
Version History
Introduced in R2023b