# realp

Real tunable parameter

## Syntax

```p = realp(paramname,initvalue) ```

## Description

`p = realp(paramname,initvalue)` creates a tunable real-valued parameter with name specified by `paramname` and initial value `initvalue`. Tunable real parameters can be scalar- or matrix- valued.

## Input Arguments

 `paramname` Name of the `realp` parameter `p`, specified as a character vector such as `'a'` or `'zeta'`. This input argument sets the value of the `Name` property of `p`. `initvalue` Initial numeric value of the parameter `p`. `initvalue` can be a real scalar value or a 2-dimensional matrix.

## Output Arguments

 `p` `realp` parameter object.

## Properties

 `Name` Name of the `realp` parameter object, stored as a character vector. The value of `Name` is set by the `paramname` input argument to `realp` and cannot be changed. `Value` Value of the tunable parameter. `Value` can be a real scalar value or a 2-dimensional matrix. The initial value is set by the `initvalue` input argument. The dimensions of `Value` are fixed on creation of the `realp` object. `Minimum` Lower bound for the parameter value. The dimension of the `Minimum` property matches the dimension of the `Value` property. For matrix-valued parameters, use indexing to specify lower bounds on individual elements: ``` p = realp('K',eye(2)); p.Minimum([1 4]) = -5;``` Use scalar expansion to set the same lower bound for all matrix elements: `p.Minimum = -5;` Default: `-Inf` for all entries `Maximum` Upper bound for the parameter value. The dimension of the `Maximum` property matches the dimension of the `Value` property. For matrix-valued parameters, use indexing to specify upper bounds on individual elements: ``` p = realp('K',eye(2)); p.Maximum([1 4]) = 5;``` Use scalar expansion to set the same upper bound for all matrix elements: `p.Maximum = 5;` Default: `Inf` for all entries `Free` Boolean value specifying whether the parameter is free to be tuned. Set the `Free` property to 1 (`true`) for tunable parameters, and 0 (`false`) for fixed parameters. The dimension of the `Free` property matches the dimension of the `Value` property. Default: 1 (`true`) for all entries

## Examples

collapse all

In this example, you will create a low-pass filter with one tunable parameter a:

`$F=\frac{a}{s+a}$`

Since the numerator and denominator coefficients of a `tunableTF` block are independent, you cannot use `tunableTF` to represent `F`. Instead, construct `F` using the tunable real parameter object `realp`.

Create a real tunable parameter with an initial value of `10`.

`a = realp('a',10)`
```a = Name: 'a' Value: 10 Minimum: -Inf Maximum: Inf Free: 1 Real scalar parameter. ```

Use `tf` to create the tunable low-pass filter `F`.

```numerator = a; denominator = [1,a]; F = tf(numerator,denominator)```
```F = Generalized continuous-time state-space model with 1 outputs, 1 inputs, 1 states, and the following blocks: a: Scalar parameter, 2 occurrences. Type "ss(F)" to see the current value, "get(F)" to see all properties, and "F.Blocks" to interact with the blocks. ```

`F` is a `genss` object which has the tunable parameter `a` in its `Blocks` property. You can connect `F` with other tunable or numeric models to create more complex control system models. For an example, see Control System with Tunable Components.

Create a matrix with tunable diagonal elements and with off-diagonal elements fixed to zero.

Create a parametric matrix whose initial value is the identity matrix.

`p = realp('P',eye(2));`

`p` is a 2-by-2 parametric matrix. Since the initial value is the identity matrix, the off-diagonal initial values are zero.

Fix the values of the off-diagonal elements by setting the `Free` property to `false`.

```p.Free(1,2) = false; p.Free(2,1) = false;```

## Tips

• Use arithmetic operators (`+`, `-`, `*`, `/`, `\`, and `^`) to combine `realp` objects into rational expressions or matrix expressions. You can use the resulting expressions in model-creation functions such as `tf`, `zpk`, and `ss` to create tunable models. For more information about tunable models, see Models with Tunable Coefficients in the Control System Toolbox™ User's Guide.