How to create continuous-time single-input, single-output (SISO) models.
|On this page…|
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 :
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:
This example shows how to create single-input, single-output (SISO) transfer functions in factored form using zpk.
Create the factored transfer function :
Z = ; 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.
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:
where the state variables are the angular position θ and angular velocity dθ/dt:
u is the electric current, the output y is the angular velocity, and the state-space matrices are:
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:
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.
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:
Load the frequency response data in AnalyzerData.mat.
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.
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.
How to create models representing PID controllers.
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.
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.
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:
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.
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:
Kp = 29.5; Ti = 1.13; Td = 0.15; N = 2.3; C = pid(Kp,Ki,Kd,Tf)
C is a pidstd model object, which is a data container for representing standard-form PID controllers.