Main Content

partrepo.simscape.dataSetFromBlock

Create block data set from Simscape block

Since R2025a

    Description

    blockDataSet = partrepo.simscape.dataSetFromBlock(blockName) returns the partrepo.simscape.BlockDataSet object for a Simscape block, blockName.

    example

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

    example

    Examples

    collapse all

    This example shows how to create a block data set from 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)
    

    This example shows how to create a block data set 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");
    

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

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

    Create a block data set from the Capacitor block. Use the EvaluateParameters argument.

    myDataSet = partrepo.simscape.dataSetFromBlock(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 include only active parameters in the block data set, specified as a logical value. When you set this argument to true, the function includes only the active parameters in the block data set. When you set this argument to false, the block data set includes all block parameters.

    Example: partrepo.simscape.dataSetFromBlock(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.dataSetFromBlock(blockDataSet,EvaluateParameters=true)

    Data Types: logical

    Output Arguments

    collapse all

    Block data set, returned as a partrepo.simscape.BlockDataSet object.

    Version History

    Introduced in R2025a