Main Content

partrepo.simscape.paramsFromBlock

Get the parameter data from a Simscape block

Since R2025a

    Description

    params = partrepo.simscape.paramsFromBlock(blockName) returns the parameter data from the block, blockName. The function returns the parameter data as a BlockDataSet.Parameter object.

    example

    params = partrepo.simscape.paramsFromBlock(___,Name,Value) returns the parameter data using name-value arguments.

    example

    Examples

    collapse all

    This example shows how to apply block parameter data to a BlockDataSet object.

    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)
    

    Update a parameter value in the Capacitor block.

    set_param(blockHandle,'c','1e-5')
    

    Update the block data set using the updated block values.

    myDataSet.Parameters = partrepo.simscape.paramsFromBlock(blockHandle);
    disp(myDataSet.Parameters)
      Parameters with properties:
    
        c: 1e-5 (F)     | 
        g: 0 (1/Ohm)    | 
        r: 1e-6 (Ohm)   | 

    This example shows how to get block parameter data from a block that includes both active and inactive parameters with all parameter expressions evaluated.

    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)
    

    Update a parameter value in the Capacitor block to use an unresolved expression.

    capacitance = 1*10^(-5);
    set_param(blockName,'c','capacitance')
    

    Update the block data set using the updated parameter values. Use the EvaluateParameters argument.

    myDataSet.Parameters = partrepo.simscape.paramsFromBlock(blockName,EvaluateParameters=true);
    disp(myDataSet.Parameters)
     Parameters with properties:
    
        c: 1e-05 (F)     | 
        g: 0 (1/Ohm)     | 
        r: 1e-06 (Ohm)   | 
    

    Input Arguments

    collapse all

    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

    Name-Value Arguments

    collapse all

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Example: partrepo.simscape.dataSetFromBlock(blockDataSet,ActiveParametersOnly=false)

    Option to only display active parameters or all parameters, specified as a logical value. When you set this argument to true, Simscape generates the block data set with only the active parameters included.

    Example: partrepo.simscape.paramsFromBlock(blockDataSet,ActiveParametersOnly=false)

    Data Types: logical

    Option to evaluate unresolved parameters, specified as a logical value. When you set this argument to true, Simscape evaluates each parameter.

    Example: partrepo.simscape.paramsFromBlock(blockDataSet,EvaluateParameters=true)

    Data Types: logical

    Output Arguments

    collapse all

    Simscape block parameters, returned as a partrepo.simscape.BlockDataSet.Parameters object.

    Version History

    Introduced in R2025a