Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

# getBlockValue

Current value of Control Design Block in Generalized Model

## Syntax

```val = getBlockValue(M,blockname) [val1,val2,...] = getBlockValue(M,blockname1,blockname2,...) S = getBlockValue(M) ```

## Description

`val = getBlockValue(M,blockname)` returns the current value of the Control Design Block `blockname` in the Generalized Model `M`. (For uncertain blocks, the “current value” is the nominal value of the block.)

`[val1,val2,...] = getBlockValue(M,blockname1,blockname2,...)` returns the values of the specified Control Design Blocks.

`S = getBlockValue(M)` returns the values of all Control Design Blocks of the generalized model in a structure. This syntax lets you transfer the block values from one generalized model to another model that uses the same Control Design Blocks, as follows:

```S = getBlockValue(M1); setBlockValue(M2,S);```

## Input Arguments

 `M` Generalized LTI (`genss`) model or generalized matrix (`genmat`). `blockname` Name of the Control Design Block in the model `M` whose current value is evaluated. To get a list of the Control Design Blocks in `M`, enter `M.Blocks`.

## Output Arguments

 `val` Numerical LTI model or numerical value, equal to the current value of the Control Design Block `blockname`. `S` Current values of all Control Design Blocks in `M`, returned as a structure. The names of the fields in `S` are the names of the blocks in `M`. The values of the fields are numerical LTI models or numerical values equal to the current values of the corresponding Control Design Blocks.

## Examples

### Get Current Values of Single Blocks

Create a tunable `genss` model, and evaluate the current value of the Control Design Blocks of the model.

Typically, you use `getBlockValue` to retrieve the tuned values of control design blocks after tuning the `genss` model using a tuning command such as `systune`. For this example, create the model and retrieve the initial block values.

```G = zpk([],[-1,-1],1); C = tunablePID('C','PID'); a = realp('a',10); F = tf(a,[1 a]); T = feedback(G*C,1)*F; Cval = getBlockValue(T,'C')```
```Continuous-time I-only controller: 1 Ki * --- s With Ki = 0.001```

`Cval` is a numeric `pid` controller object.

`aval = getBlockValue(T,'a')`
```aval = 10```

`aval` is a numeric scalar, because `a` is a real scalar parameter.

### Get All Current Values as Structure

Using the `genss` model of the previous example, get the current values of all blocks in the model.

```G = zpk([],[-1,-1],1); C = tunablePID('C','PID'); a = realp('a',10); F = tf(a,[1 a]); T = feedback(G*C,1)*F; S = getBlockValue(T)```
```S = C: [1x1 pid] a: 10 ```

## See Also

### Topics

#### Learn how to automatically tune PID controller gains

Download code examples