Documentation

# set

Set or modify model properties

## Syntax

```set(sys,'Property',Value) set(sys,'Property1',Value1,'Property2',Value2,...) sysnew = set(___) set(sys,'Property') ```

## Description

`set` is used to set or modify the properties of a dynamic system model using property name/property value pairs.

`set(sys,'Property',Value) ` assigns the value `Value` to the property of the model `sys`. `'Property'` can be the full property name (for example, `'UserData'`) or any unambiguous case-insensitive abbreviation (for example, `'user'`). The specified property must be compatible with the model type. For example, if `sys` is a transfer function, `Variable` is a valid property but `StateName` is not. For a complete list of available system properties for any linear model type, see the reference page for that model type. This syntax is equivalent to `sys.Property = Value`.

`set(sys,'Property1',Value1,'Property2',Value2,...)` sets multiple property values with a single statement. Each property name/property value pair updates one particular property.

`sysnew = set(___)` returns the modified dynamic system model, and can be used with any of the previous syntaxes.

`set(sys,'Property')` displays help for the property specified by `'Property'`.

## Examples

collapse all

Create a SISO state-space model with matrices A, B, C, and D equal to 1, 2, 3, and 4, respectively.

`sys = ss(1,2,3,4);`

Modify the properties of the model. Add an input delay of 0.1 second, label the input as `torque`, and set the D matrix to 0.

`set(sys,'InputDelay',0.1,'InputName','torque','D',0);`

View the model properties, and verify the changes.

`get(sys)`
``` A: 1 B: 2 C: 3 D: 0 E: [] Scaled: 0 StateName: {''} StateUnit: {''} InternalDelay: [0x1 double] InputDelay: 0.1000 OutputDelay: 0 Ts: 0 TimeUnit: 'seconds' InputName: {'torque'} InputUnit: {''} InputGroup: [1x1 struct] OutputName: {''} OutputUnit: {''} OutputGroup: [1x1 struct] Notes: [0x1 string] UserData: [] Name: '' SamplingGrid: [1x1 struct] ```

## Tips

For discrete-time transfer functions, the convention used to represent the numerator and denominator depends on the choice of variable (see `tf` for details). Like `tf`, the syntax for `set` changes to remain consistent with the choice of variable. For example, if the `Variable` property is set to `'z'` (the default),

```set(h,'num',[1 2],'den',[1 3 4]) ```

produces the transfer function

`$h\left(z\right)=\frac{z+2}{{z}^{2}+3z+4}$`

However, if you change the `Variable` to `'z^-1'` by

```set(h,'Variable','z^-1'), ```

the same command

```set(h,'num',[1 2],'den',[1 3 4]) ```

now interprets the row vectors `[1 2]` and ```[1 3 4]``` as the polynomials 1 + 2z−1 and 1 + 3z−1 + 4z−2 and produces:

`$\overline{h}\left({z}^{-1}\right)=\frac{1+2{z}^{-1}}{1+3{z}^{-1}+4{z}^{-2}}=zh\left(z\right)$`

### Note

Because the resulting transfer functions are different, make sure to use the convention consistent with your choice of variable.

## See Also

### Topics

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

Download code examples