メインコンテンツ

partrepo.collection.applyDataSet

Apply part to block

Since R2026a

    Description

    partrepo.collection.applyDataSet(blockName,collectionID,partID) applies the part, partID, from the collection, collectionID, to the block, blockName.

    example

    partrepo.collection.applyDataSet(blockName,partsTable) applies the specified table row, partsTable, to the block.

    Examples

    collapse all

    This example shows how to apply a part from an installed collection to a Simscape block.

    Install Collection

    The MyResistors_1.0.0.mldatx file is a collection with three parts that parameterize the Resistor block in the Simscape foundation library. To install the collection, double-click the file or enter:

    partrepo.collection.install("MyResistors_1.0.0.mldatx")
    Successfully installed part collection. Details:
    
       Collection ID: MyOrg.MyResistors 
       Version: 1.0.0 
       
       Data set IDs:
          MyManufacturer|R-0001|Resistor 1
          MyManufacturer|R-0002|Resistor 2
          MyManufacturer|R-0003|Resistor 3 
       
       Blocks with data sets from this collection:
          fl_lib/Electrical/Electrical Elements/Resistor
    

    To view information about the collection, use the partrepo.collection.listDataSets function. The collection ID is MyOrg.MyResistors.

    partsTable = partrepo.collection.listDataSets("MyOrg.MyResistors")
    partsTable=3×2 table
           CollectionId                      PartId              
        ___________________    __________________________________
    
        "MyOrg.MyResistors"    "MyManufacturer|R-0001|Resistor 1"
        "MyOrg.MyResistors"    "MyManufacturer|R-0002|Resistor 2"
        "MyOrg.MyResistors"    "MyManufacturer|R-0003|Resistor 3"
    
    

    Apply Part to Simscape Block

    The MyResistorModel model contains three Simscape foundation library Resistor blocks in parallel. Open the model.

    open("MyResistorModel")
    ans = logical
       1
    
    

    You can apply any of the parts to any of the Resistor blocks in the model. To apply the MyManufacturer|R-0001|Resistor 1 part to the block labeled Resistor 1, use the partrepo.collection.applyDataSet function.

    partrepo.collection.applyDataSet("MyResistorModel/Resistor 1","MyOrg.MyResistors","MyManufacturer|R-0001|Resistor 1")

    This example shows how to apply a part from an installed collection using a table entry.

    Install a Collection

    The MyResistors_1.0.0.mldatx file is a collection with three parts to parameterize the Resistor block in the Simscape foundation library. Install the collection.

    partrepo.collection.install("MyResistors_1.0.0.mldatx",Overwrite=true)
    Successfully installed part collection. Details:
    
       Collection ID: MyOrg.MyResistors 
       Version: 1.0.0 
       
       Data set IDs:
          MyManufacturer|R-0001|Resistor 1
          MyManufacturer|R-0002|Resistor 2
          MyManufacturer|R-0003|Resistor 3 
       
       Blocks with data sets from this collection:
          fl_lib/Electrical/Electrical Elements/Resistor
    

    To view information about the collection, use the partrepo.collection.listDataSets function. The collection ID is MyOrg.MyResistors.

    partsTable = partrepo.collection.listDataSets("MyOrg.MyResistors")
    partsTable=3×2 table
           CollectionId                      PartId              
        ___________________    __________________________________
    
        "MyOrg.MyResistors"    "MyManufacturer|R-0001|Resistor 1"
        "MyOrg.MyResistors"    "MyManufacturer|R-0002|Resistor 2"
        "MyOrg.MyResistors"    "MyManufacturer|R-0003|Resistor 3"
    
    

    Apply a Part Using a Table Entry

    The MyResistorModel model contains three Simscape foundation library Resistor blocks in parallel. Open the model.

    open("MyResistorModel")
    ans = logical
       1
    
    

    You can apply any of the parts to any of the Resistor blocks in the model. To apply the MyManufacturer|R-0002|Resistor 2 part to the block labeled Resistor 2, specify its row in the partsTable table as an argument in the partrepo.collection.applyDataSet function.

    R2_row = partsTable(2,:);
    partrepo.collection.applyDataSet("MyResistorModel/Resistor 2",R2_row)

    Input Arguments

    collapse all

    Simscape block to apply the part data set, specified as a string scalar, character vector, or block handle.

    Collection ID for the part to apply, specified as a string scalar or character vector.

    Part ID for the collection to apply, specified as a string scalar or character vector.

    Table row that contains the collection ID and part ID of the part to apply as the first and second columns, respectively, specified as a table.

    Version History

    Introduced in R2026a