Main Content


Add structure type to Architectural Data section of Simulink data dictionary

Since R2023b



    dataType = addStructType(archDataObj,dataTypeName) adds a Simulink.Bus type specified by dataTypeName to archDataObj, the Architectural Data section of the data dictionary.


    dataType = addStructType(archDataObj,dataTypeName,SimulinkBus=busObj) adds a structure type that is the same as the specified Simulink.Bus object, busObj, to the data dictionary.


    collapse all

    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 =;

    Add a structured data type to the Architectural Data section of the data dictionary. You can specify the name, data type, and dimensions using the addStructType 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 =;

    Create a Simulink.Bus object and add elements using the Simulink.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 the Simulink.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

    collapse all

    Architectural Data object, specified as a Simulink.dictionary.ArchitecturalData object.

    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

    collapse all

    Structure type object, returned as a Simulink.dictionary.archdata.StructureType object containing structure elements, with Simulink.Bus as the underlying implementation.

    Version History

    Introduced in R2023b