How to create continuoustime singleinput, singleoutput (SISO) models.
This example shows how to create continuoustime singleinput, singleoutput (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 s^{2} + 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:

This example shows how to create singleinput, singleoutput
(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+1i\right)\left(s+2\right)}$$:
Z = [0]; P = [11i 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 = [11i 1+1i 2]
specifies these
pole locations.
G
is
a zpk
model object, which
is a data container for representing transfer functions in zeropolegain
(factorized) form.
This example shows how to create a continuoustime singleinput, singleoutput (SISO) statespace
model from
statespace matrices using ss
.
Create a model of an electric motor where the statespace 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 dθ/dt:
$$x=\left[\begin{array}{c}\theta \\ \frac{d\theta}{dt}\end{array}\right],\text{\hspace{1em}}\text{\hspace{1em}}$$
u is the electric current, the output y is the angular velocity, and the statespace matrices are:
$$A=\left[\begin{array}{cc}0& 1\\ 5& 2\end{array}\right],\text{\hspace{1em}}B=\left[\begin{array}{c}0\\ 3\end{array}\right],\text{\hspace{1em}}C=\left[\text{\hspace{0.05em}}\begin{array}{cc}0& 1\end{array}\right],\text{\hspace{1em}}D=\left[\text{\hspace{0.05em}}0\text{\hspace{0.05em}}\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 statespace models.
Tip To represent a system of the form: $$\begin{array}{c}E\frac{dx}{dt}=Ax+Bu\\ y=Cx+Du\end{array}$$ use 
This example shows how to create a singleinput, singleoutput
(SISO) frequencyresponse model using frd
.
A frequencyresponse 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:
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 complexvalued frequency
response points, respectively.
Tip To inspect these variables, enter: whos freq resp 
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 frequencydomain
analysis commands. For example, visualize the frequency response data
using bode
.
Tip
By default, the sys = frd(resp,freq,'TimeUnit','min','FrequencyUnit','rad/TimeUnit') sets the frequency units to radians/minute. 
How to create models representing PID controllers.
You can represent continuoustime ProportionalIntegralDerivative (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.
Form  Formula 

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

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

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 DiscreteTime ProportionalIntegralDerivative (PID) Controller for information on creating PID Controllers in discrete time.
This example shows how to create a continuoustime ProportionalIntegralDerivative
(PID) controller in parallel form using pid
.
Create the following parallelform 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 parallelform PID controllers.
This example shows how to create a continuoustime ProportionalIntegralDerivative
(PID) controller in standard form using pidstd
.
Create the following standardform 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 standardform PID controllers.