Main Content

applyParams

Apply parameters from block data set to Simscape block

Since R2025a

    Description

    applyParams(BlockDataSet,BlockName) applies the parameters from the partrepo.simscape.BlockDataSet object, BlockDataSet, to the Simscape block, BlockName.

    example

    Examples

    collapse all

    This example shows how to create a BlockDataSet object from a block, edit it, and apply it to a Simscape block

    Create a model with a Simscape block. This example uses a Capacitor block from the Foundation Library.

    modelName = "myModel";
    close_system(modelName,0) 
    libraryBlockName = "fl_lib/Electrical/Electrical Elements/Capacitor";
    open_system(new_system(modelName));
    blockName = add_block(libraryBlockName,modelName + "/" + "Example block");
    

    Create a block data set from the Capacitor block.

    myDataSet = partrepo.simscape.dataSetFromBlock(blockName)
    myDataSet = 
    
      BlockDataSet with properties:
    
                ID: "||" (format)
          Metadata: [1×1 Metadata] (11 entries, Incomplete)
        Parameters: [1×1 Parameters] (3 entries)
    

    Change the parameter data in the block.

    set_param(blockName,'c','5e-6')

    When you apply the block data set to the block, the function overwrites the current block parameter data.

    applyParams(myDataSet,blockName)

    Input Arguments

    collapse all

    Block data set to apply to a Simscape block, specified as a partrepo.simscape.BlockDataSet object.

    Simscape block name, specified as a string scalar or character vector that contains a block name, or a block handle.

    Data Types: double | char | string

    Version History

    Introduced in R2025a