The Continuous Blocks Library
3.1 The Continuous − Time Linear Systems Sub − Library
3.1.2 The Derivative Block
The Derivative block approximates the derivative of its input. The initial output for the block is zero. The accuracy of the results depends on the size of the time steps taken in the simulation.
Smaller steps allow a smoother and more accurate output curve from this block. Unlike blocks that have continuous states, the solver does not take smaller steps when the input changes rap-idly. Let us consider the following simple example.
Example 3.1
We will create a model that will compute and display the waveform of the derivative of the func-tion .
The model is shown in Figure 3.1, and the input and output waveforms are shown in Figure 3.2.
Figure 3.1. Model for Example 3.1
To convert the sine function in the Sine Wave block to a cosine function, in the Source Block Parameters dialog box we specify . As we know, the derivative of the cosine func-tion is the negative of the sine funcfunc-tion and this is shown in Figure 3.2.
y = cosx
Phase = π 2⁄
SOFTbank E-Book Center Tehran, Phone: 66403879,66493070 For Educational Use.
Introduction to Simulink with Engineering Applications 3−3 Copyright © Orchard Publications
To scale the vertical axis in Figure 3.2, we move the cursor near that axis, we right−click, and we set the values as indicated. We will follow this practice in subsequent illustrations.
Figure 3.2. Input and output waveforms for the model of Figure 3.1
The Simulink Help for the derivative block states that using the MATLAB function linmod to linearize a model that contains a Derivative block can be troublesome. Let us elaborate on linear-ization.
We prefer to work with linear functions since the slope is constant and thus we can find the out-put for any inout-put. Unfortunately, the equations that describe the behavior of most physical phe-nomena are non−linear. If we are interested in values of the function close to some point (a,b), we can replace the given function by its first Taylor polynomial, which is a linear function.* We recall that the Taylor series are defined as in relation (3.1) below.
(3.1) In (3.1), the first two terms on the right side define an equation of a straight line, i.e., , a linear function. For example, if , the first two terms on the right side of (3.1) at point x=3 are represented by . The same is true for a function of two vari-ables, say and , i.e., , where if we let denote the local linearization at the point , we get
(3.2)
* The first Taylor polynomial is often called the local linearization.
f x( ) f x( ) f ′ x0 ( ) x x0 ( – 0) f ′′ x( )0
SOFTbank E-Book Center Tehran, Phone: 66403879,66493070 For Educational Use.
3−4 Introduction to Simulink with Engineering Applications
Copyright © Orchard Publications
Relation (3.2) yields the three numbers required to define the local linearization. The first number is the value of at point , the second is the value of the partial derivative with respect to at point , and the third is the value of the partial derivative with respect to at point . Taking the partial derivative of and evaluating it at the point we find
that the local linearization is . We observe that this local
linearization contains and terms of first degree. We can plot these functions with the follow-ing MATLAB script. The plot is shown in Figure 3.3.
x=-3:0.01:3; y=x; z=x.^2+y.^2;...
w=5+2.*(x−1)+4.*(y−2);...
plot(x,z,x,w); grid
Figure 3.3. An example of linearization at a specified point
MATLAB provides three functions to extract linear functions in the form of state−space matrices , , , and . We recall that the input−output relationship in terms of these matrices is
(3.3) where represents the state(s), the input, and the output, and the inputs and outputs must be Inport and Outport blocks. Other blocks cannot be used as inputs and outputs.
Example 3.2
We will use the MATLAB linmod(‘x’) function to extract the linear model for the model shown in Figure 3.4.
We save the given model as Figure_3_4, and in MATLAB’s Command Window we execute the command [A,B,C,D]=linmod('Figure_3_4'). MATLABdisplays the four matrices as
f (a b, ) x
SOFTbank E-Book Center Tehran, Phone: 66403879,66493070 For Educational Use.
Introduction to Simulink with Engineering Applications 3−5 Copyright © Orchard Publications
Figure 3.4. Model for Example 3.2 A =
and thus the model of Figure 3.4 can be represented as
The Simulink Extras library contains the Switched derivative for linearization block and the Switched transport delay for linearization block. The former should be used in place of the derivative when we are linearizing the model. It approximates the derivative with a proper trans-fer function. The latter delays the input by a specified amount of time. It can be used to simulate a time delay.
To avoid possible problems with derivatives we can incorporate the derivative block in other blocks.
Example 3.3
Let us consider the model of Figure 3.5.
x·
SOFTbank E-Book Center Tehran, Phone: 66403879,66493070 For Educational Use.
3−6 Introduction to Simulink with Engineering Applications
Copyright © Orchard Publications
Figure 3.5. Model with derivative block
Recalling that differentiation in the time domain corresponds to multiplication by in the com-plex frequency domain minus the initial value of at , that is,
and assuming that the initial value is zero, we can replace the model of Figure 3.5 with that of Fig-ure 3.6.
Figure 3.6. Model equivalent to the model of Figure 3.5