# Documentation

## SISO Model Creation

How to create continuous-time single-input, single-output (SISO) models.

### Transfer Function Model Using Numerator and Denominator Coefficients

This example shows how to create continuous-time single-input, single-output (SISO) transfer functions from their numerator and denominator coefficients using `tf`.

Create the transfer function $G\left(s\right)=\frac{s}{{s}^{2}+3s+2}$:

```num = [1 0]; den = [1 3 2]; G = tf(num,den); ```

`num` and `den` are the numerator and denominator polynomial coefficients in descending powers of s. For example, `den = [1 3 2]` represents the denominator polynomial s2 + 3s + 2.

`G` is a `tf` model object, which is a data container for representing transfer functions in polynomial form.

 Tip   Alternatively, you can specify the transfer function G(s) as an expression in s:Create a transfer function model for the variable s.`s = tf('s'); `Specify G(s) as a ratio of polynomials in s.`G = s/(s^2 + 3*s + 2); `

### Transfer Function Model Using Zeros, Poles, and Gain

This example shows how to create single-input, single-output (SISO) transfer functions in factored form using `zpk`.

Create the factored transfer function $G\left(s\right)=5\frac{s}{\left(s+1+i\right)\left(s+1-i\right)\left(s+2\right)}$:

```Z = [0]; P = [-1-1i -1+1i -2]; K = 5; G = zpk(Z,P,K); ```

`Z` and `P` are the zeros and poles (the roots of the numerator and denominator, respectively). `K` is the gain of the factored form. For example, G(s) has a real pole at s = –2 and a pair of complex poles at s = –1 ± i. The vector `P = [-1-1i -1+1i -2]` specifies these pole locations.

`G` is a `zpk` model object, which is a data container for representing transfer functions in zero-pole-gain (factorized) form.

### State-Space Model

This example shows how to create a continuous-time single-input, single-output (SISO) state-space model from state-space matrices using `ss`.

Create a model of an electric motor where the state-space equations are:

$\begin{array}{c}\frac{dx}{dt}=Ax+Bu\\ y=Cx+Du\end{array}$

where the state variables are the angular position θ and angular velocity /dt:

$x=\left[\begin{array}{c}\theta \\ \frac{d\theta }{dt}\end{array}\right],\text{ }\text{ }$

u is the electric current, the output y is the angular velocity, and the state-space matrices are:

$A=\left[\begin{array}{cc}0& 1\\ -5& -2\end{array}\right],\text{ }B=\left[\begin{array}{c}0\\ 3\end{array}\right],\text{ }C=\left[\text{ }\begin{array}{cc}0& 1\end{array}\right],\text{ }D=\left[\text{ }0\text{ }\right].$

To create this model, enter:

```A = [0 1;-5 -2]; B = [0;3]; C = [0 1]; D = 0; sys = ss(A,B,C,D); ```

`sys` is an `ss` model object, which is a data container for representing state-space models.

 Tip   To represent a system of the form: $\begin{array}{c}E\frac{dx}{dt}=Ax+Bu\\ y=Cx+Du\end{array}$use `dss`. This command creates a `ss` model with a nonempty `E` matrix, also called a descriptor state-space model. See MIMO Descriptor State-Space Model for an example.

### Frequency-Response Model

This example shows how to create a single-input, single-output (SISO) frequency-response model using `frd`.

A frequency-response model stores a vector of frequency points with corresponding complex frequency response data you obtain either through simulations or experimentally. Thus, if you measure the frequency response of your system at a set of test frequencies, you can use the data to create a frequency response model:

1. Load the frequency response data in `AnalyzerData.mat`.

`load AnalyzerData`

This command loads the data into the MATLAB® workspace as the column vectors `freq` and `resp`. The variables `freq` and `resp` contain 256 test frequencies and the corresponding complex-valued frequency response points, respectively.

 Tip   To inspect these variables, enter:`whos freq resp`
2. Create a frequency response model.

`sys = frd(resp,freq);`

`sys` is an `frd` model object, which is a data container for representing frequency response data.

You can use `frd` models with many frequency-domain analysis commands. For example, visualize the frequency response data using `bode`.

 Tip   By default, the `frd` command assumes that the frequencies are in radians/second. To specify different frequency units, use the `TimeUnit` and `FrequencyUnit` properties of the `frd` model object. For example:`sys = frd(resp,freq,'TimeUnit','min','FrequencyUnit','rad/TimeUnit') `sets the frequency units to radians/minute.

### Proportional-Integral-Derivative (PID) Controller

How to create models representing PID controllers.

#### Continuous-Time PID Controller Representations

You can represent continuous-time Proportional-Integral-Derivative (PID) controllers in either parallel or standard form. The two forms differ in the parameters used to express the proportional, integral, and derivative actions and the filter on the derivative term, as shown in the following table.

FormFormula
Parallel

$C={K}_{p}+\frac{{K}_{i}}{s}+\frac{{K}_{d}s}{{T}_{f}s+1},$

where:

• Kp = proportional gain

• Ki = integrator gain

• Kd = derivative gain

• Tf = derivative filter time

Standard

$C={K}_{p}\left(1+\frac{1}{{T}_{i}s}+\frac{{T}_{d}s}{\frac{{T}_{d}}{N}s+1}\right),$

where:

• Kp = proportional gain

• Ti = integrator time

• Td = derivative time

• N = derivative filter constant

Use a controller form that is convenient for your application. For example, if you want to express the integrator and derivative actions in terms of time constants, use Standard form.

See Discrete-Time Proportional-Integral-Derivative (PID) Controller for information on creating PID Controllers in discrete time.

#### Create Continuous-Time Parallel-Form PID Controller

This example shows how to create a continuous-time Proportional-Integral-Derivative (PID) controller in parallel form using `pid`.

Create the following parallel-form PID controller: $C=29.5+\frac{26.2}{s}-\frac{4.3s}{0.06s+1}.$

```Kp = 29.5; Ki = 26.2; Kd = 4.3; Tf = 0.06; C = pid(Kp,Ki,Kd,Tf)```

C is a `pid` model object, which is a data container for representing parallel-form PID controllers.

#### Create Continuous-Time Standard-Form PID Controller

This example shows how to create a continuous-time Proportional-Integral-Derivative (PID) controller in standard form using `pidstd`.

Create the following standard-form PID controller: $C=29.5\left(1+\frac{1}{1.13s}+\frac{0.15s}{\frac{0.15}{2.3}s+1}\right).$

```Kp = 29.5; Ti = 1.13; Td = 0.15; N = 2.3; C = pidstd(Kp,Ti,Td,N)```

C is a `pidstd` model object, which is a data container for representing standard-form PID controllers.