Main Content

param.Continuous

Continuous tunable parameter

Description

A continuous parameter is a numeric parameter that can take any value in a specified interval. The parameter can be scalar-valued or array-valued.

Typically, you use continuous parameters to create parametric models and to estimate or optimize tunable parameters in such models. For instance, when performing response optimization or parameter estimation with sdo.optimize, use sdo.getParameterFromModel to create param.Continuous objects corresponding to parameters in your Simulink® model.

Creation

Create a continuous parameter object in one of the following ways.

  • sdo.getParameterFromModel to create objects corresponding to continuous-valued parameters in a Simulink model.

  • param.Continuous function.

Description

p = param.Continuous(name) creates a scalar parameter and sets the Name property. The remaining properties of the object have default values.

p = param.Continuous(name,value) creates a parameter with the same dimensions as value and sets the Value property.

example

Properties

expand all

This property is read-only.

Parameter name, specified as a character vector or string scalar and stored as a character vector. Set Name at object creation.

Parameter value, specified as a scalar or array. The dimensions of this property determine the dimensions of the parameter. Set Value at object creation.

Lower bound for the parameter value, specified as a scalar or array. The dimensions of this property match the dimensions of the Value property.

For array-valued parameters, you can:

  • Specify lower bounds on individual array elements, for example, p.Minimum([1 4]) = -5.

  • Use scalar expansion to set the lower bound for all array elements. For example, p.Minimum = -5.

Upper bound for the parameter value, specified as a scalar or array. The dimensions of this property match the dimensions of the Value property.

For array-valued parameters, you can:

  • Specify upper bounds on individual array elements. For example, p.Maximum([1 4]) = 5.

  • Use scalar expansion to set the upper bound for all array elements. For example, p.Maximum = 5.

Indication of whether parameter is tunable, specified as numeric or logical 1 (true) or 0 (false) or an array of such values.

For scalar parameters:

  • Free = 1 (true) means the parameter is tunable during optimization.

  • Free = 0 (false) means the parameter value is fixed during optimization.

For array-valued parameters, the dimensions of Free match the dimensions of the Value property. For array-valued parameters, you can:

  • Fix individual array elements. For example, p.Free = [1 0; 0 1] fixes the off-diagonal elements of a 2-by-2 matrix-valued parameter during optimization but allows the diagonal elements to be tuned. Similarly, p.Free([2 3]) = 0 fixes the second and third elements in p.

  • Use scalar expansion to fix all array elements. For example, p.Free = false fixes the values of all elements of p during optimization.

Scaling factor for normalizing the parameter value, specified as a scalar or array. The dimensions of this property match the dimensions of the Value property.

For array-valued parameters, you can:

  • Specify scaling for individual array elements. For example, p.Scale([1 4]) = 1.

  • Use scalar expansion to set the scaling for all array elements. For example, p.Scale = 1.

Parameter units and labels, specified as a structure array with fields Label and Unit. The array dimension must match the dimension of the Value property.

Use this property to store parameter units and labels that describe the parameter. For example, p.Info(1,1).Unit = 'N/m'; or p.Info(1,1).Label = 'spring constant'.

The default value for both the Label and Unit fields is ''.

Object Functions

isrealDetermine if parameter value, minimum, and maximum are real

Examples

collapse all

Load a Simulink model.

load_system("sldo_model1_stepblk")

If you do not specify any model parameters, sdo.getParameterFromModel finds all the tunable parameters in the model and treats them as continuous parameters.

DesignVars = sdo.getParameterFromModel("sldo_model1_stepblk");
DesignVars
 
DesignVars(1,1) =
 
       Name: 'Kd'
      Value: 0
    Minimum: -Inf
    Maximum: Inf
       Free: 1
      Scale: 1
       Info: [1x1 struct]

 
DesignVars(2,1) =
 
       Name: 'Ki'
      Value: 0
    Minimum: -Inf
    Maximum: Inf
       Free: 1
      Scale: 1
       Info: [1x1 struct]

 
DesignVars(3,1) =
 
       Name: 'Kp'
      Value: 1
    Minimum: -Inf
    Maximum: Inf
       Free: 1
      Scale: 1
       Info: [1x1 struct]

 
DesignVars(4,1) =
 
       Name: 'w0'
      Value: 0.5000
    Minimum: -Inf
    Maximum: Inf
       Free: 1
      Scale: 0.5000
       Info: [1x1 struct]

 
DesignVars(5,1) =
 
       Name: 'zeta'
      Value: 0.5000
    Minimum: -Inf
    Maximum: Inf
       Free: 1
      Scale: 0.5000
       Info: [1x1 struct]

 
5x1 param.Continuous
 

Thus, for this model, which has tunable parameters Kd, Ki, Kp, w0, and zeta, the output DesignVars is an array of five param.Continuous objects. To prepare the parameters for optimization, you can set the initial value, minimum and maximum values, and free elements of each parameter as needed. For instance, set the minimum value of Kd to 0.001, the maximum value to 100, and the initial value to 1.

DesignVars(1).Minimum = 1e-3;
DesginVars(1).Maximum = 100;
DesignVars(1).Value = 1;

Construct a 2-by-2 matrix-valued param.Continuous object and set its initial value to the identity matrix.

p = param.Continuous('K',eye(2)) 
 
p =
 
       Name: 'K'
      Value: [2x2 double]
    Minimum: [2x2 double]
    Maximum: [2x2 double]
       Free: [2x2 logical]
      Scale: [2x2 double]
       Info: [2x2 struct]

 
1x1 param.Continuous
 

Set the maximum value that all entries in p can take during optimization.

p.Maximum = 5;

Assign each entry a different minimum value using a 2-by-2 matrix.

p.Minimum = [-1 -10; 0.02 1];

Suppose instead that you want the diagonal elements of p to remain fixed at 1 during optimization, but let the off-diagonal elements vary. First, confirm that the current value has diagonal elements equal to 1. Then, use the Free property to fix the diagonal elements at this value.

p.Value
ans = 2×2

     1     0
     0     1

p.Free = [0 1; 1 0];

Version History

Introduced in R2012b