Dynamic System Modelling and Analysis with MATLAB and Python 1st Edition Jongrae Kim - The ebook with rich content is ready for you to download
Dynamic System Modelling and Analysis with MATLAB and Python 1st Edition Jongrae Kim - The ebook with rich content is ready for you to download
com
https://ebookmeta.com/product/dynamic-system-modelling-and-
analysis-with-matlab-and-python-1st-edition-jongrae-kim/
OR CLICK HERE
DOWLOAD EBOOK
https://ebookmeta.com/product/python-for-matlab-development-extend-
matlab-with-300000-modules-from-the-python-package-index-danial/
ebookmeta.com
https://ebookmeta.com/product/fiber-lasers-fundamentals-with-matlab-
modelling-1st-edition-johan-meyer-editor/
ebookmeta.com
https://ebookmeta.com/product/infinity-rpg-adventures-in-the-human-
sphere-1st-edition-justin-alexander/
ebookmeta.com
https://ebookmeta.com/product/hell-and-heaven-wayfinding-2-1st-
edition-hugh-howey/
ebookmeta.com
https://ebookmeta.com/product/bitty-fish-barbara-derubertis-eva-
vagreti-cockrille/
ebookmeta.com
https://ebookmeta.com/product/tras-el-llamado-1st-edition-javier-de-
la-vega-alfaro/
ebookmeta.com
Dynamic System Modelling and Analysis with MATLAB and Python
IEEE Press
445 Hoes Lane
Piscataway, NJ 08854
Jongrae Kim
University of Leeds
Leeds, UK
No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any
form or by any means, electronic, mechanical, photocopying, recording, scanning, or otherwise,
except as permitted under Section 107 or 108 of the 1976 United States Copyright Act, without
either the prior written permission of the Publisher, or authorization through payment of the
appropriate per-copy fee to the Copyright Clearance Center, Inc., 222 Rosewood Drive, Danvers,
MA 01923, (978) 750-8400, fax (978) 750-4470, or on the web at www.copyright.com. Requests to
the Publisher for permission should be addressed to the Permissions Department, John Wiley &
Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at
http://www.wiley.com/go/permission.
Limit of Liability/Disclaimer of Warranty: While the publisher and author have used their best
efforts in preparing this book, they make no representations or warranties with respect to the
accuracy or completeness of the contents of this book and specifically disclaim any implied
warranties of merchantability or fitness for a particular purpose. No warranty may be created or
extended by sales representatives or written sales materials. The advice and strategies contained
herein may not be suitable for your situation. You should consult with a professional where
appropriate. Further, readers should be aware that websites listed in this work may have
changed or disappeared between when this work was written and when it is read. Neither the
publisher nor author shall be liable for any loss of profit or any other commercial damages,
including but not limited to special, incidental, consequential, or other damages.
For general information on our other products and services or for technical support, please
contact our Customer Care Department within the United States at (800) 762-2974, outside the
United States at (317) 572-3993 or fax (317) 572-4002.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in
print may not be available in electronic formats. For more information about Wiley products,
visit our web site at www.wiley.com.
Hardback: 9781119801627
Contents
Preface xiii
Acknowledgements xv
Acronyms xvii
About the Companion Website xix
1 Introduction 1
1.1 Scope of the Book 1
1.2 Motivation Examples 2
1.2.1 Free-Falling Object 2
1.2.1.1 First Program in Matlab 4
1.2.1.2 First Program in Python 10
1.2.2 Ligand–Receptor Interactions 14
1.3 Organization of the Book 21
Exercises 21
Bibliography 22
Index 307
xiii
Preface
This book is for control engineers to learn dynamic system modelling and sim-
ulation and control design and analysis using MATLAB or Python. The readers
are assumed to have the undergraduate final-year level of knowledge on ordinary
differential equations, vector calculus, probability, and basic programming.
We have verified all the MATLAB and Python codes in the book using MATLAB
R2021a and Python 3.8 in Spyder, the scientific Python development environment.
To reduce the confusion in running a particular program, most of the programs are
independent on their own. Organizing programming with multiple files is left as
an advanced skill for readers to learn after reading this book.
Acknowledgements
Jongrae Kim
xvii
Acronyms
www.wiley.com/go/kim/dynamicmodeling
Introduction
Fg
From the kinematic relationship between the velocity, 𝑣, and the displacement,
x, we have
dx
=𝑣
dt
where the origin of x is at the initial position of the object, m, and the positive
direction of x is downwards in the figure. The right-hand side of (1.2) becomes
( )
∑ d d dx
mg = Fg = Fi = (m𝑣) = m
i
dt dt dt
Finally, the leftmost and the rightmost terms are equal to each other as follows:
( )
d dx
mg = m
dt dt
and it is expanded as follows:
dm dx d2 x
mg = +m 2
dt dt dt
Using the short notations, ṁ = dm∕dt, ẋ = dx∕dt, and ẍ = d2 x∕dt2 , and after
rearrangements, the governing equation is given by
ṁ
ẍ = g − ẋ (1.3)
m
For purely educational purposes, assume that the mass change rate is given by
ṁ = −m + 2 (1.4)
We can identify now that there are three independent time-varying states, which
̇ and the mass, m. All the other time-varying
are the position, x, the velocity, x,
states, for example, ẍ and m,
̇ can be expressed using the independent state vari-
ables. Define the state variables as follows:
x1 = x
x2 = ẋ
x3 = m
Obtain the time derivative of each state expressed in the state variable as follows:
ẋ 1 = ẋ = x2 (1.5a)
−m + 2 −x + 2
ẋ 2 = ẍ = g − ẋ = g − 3 x2 (1.5b)
m x3
ẋ 3 = ṁ = −m + 2 = −x3 + 2 (1.5c)
and this is called the state-space form.
̇
Let the initial conditions be equal to x1 (0) = x(0) = 0.0 m, x2 (0) = x(0) = 0.5 m/s,
and x3 (0) = m(0) = 5 kg. Equation (1.5) can be written in a compact form using the
4 1 Introduction
1 clear ;
2
3 g r v _ c o n s t = 9 . 8 1 ; % [m/ s ^ 2 ]
4 i n i t _ p o s = 0 . 0 ; %[m]
5 i n i t _ v e l = 0 . 5 ; % [m/ s ]
6 i n i t _ m a s s = 5 . 0 ; %[ kg ]
7
8 init_time = 0; % [ s ]
9 final_time = 5.0; % [ s ]
10 time_interval = [ init_time final_time ] ;
11
12 x0 = [ i n i t _ p o s i n i t _ v e l i n i t _ m a s s ] ;
13 [ t o u t , x o u t ] = ode45 (@( time , s t a t e ) f r e e _ f a l l i n g _ o b j ( time , s t a t e ,
g r v _ c o n s t ) , t i m e _ i n t e r v a l , x0 ) ;
14
15 f i g u r e ( 1 ) ;
16 p l o t ( t o u t , x o u t ( : , 1 ) )
17 y l a b e l ( ’ p o s i t i o n [m] ’ ) ;
1.2 Motivation Examples 5
18 x l a b e l ( ’ time [ s ] ’ ) ;
19
20 figure ( 2 ) ;
21 plot ( tout , xout ( : , 2 ) )
22 y l a b e l ( ’ v e l o c i t y [m/ s ] ’ ) ;
23 x l a b e l ( ’ time [ s ] ’ ) ;
24
25 figure ( 3 ) ;
26 plot ( tout , xout ( : , 3 ) )
27 y l a b e l ( ’m( t ) [ kg ] ’ ) ;
28 x l a b e l ( ’ time [ s ] ’ ) ;
29
30 function d x d t = f r e e _ f a l l i n g _ o b j ( time , s t a t e , g r v _ c o n s t )
31 x1 = state (1) ;
32 x2 = state (2) ;
33 x3 = state (3) ;
34
35 d x d t = zeros ( 3 , 1 ) ;
36 d x d t ( 1 ) = x2 ;
37 d x d t ( 2 ) = g r v _ c o n s t + ( x3 −2) ∗ ( x2 / x3 ) ;
38 d x d t ( 3 ) = −x3 + 2 ;
39 end
200 70
60
150
50
Velocity (m/s)
Position (m)
40
100
30
50 20
10
0 0
0 1 2 3 4 5 0 1 2 3 4 5
Time (s) Time (s)
(a) figure(1) (b) figure(2)
5
4.5
4
m(t) (kg)
3.5
2.5
2
0 1 2 3 4 5
Time (s)
(c) figure(3)
Figure 1.2 Free-falling object position, velocity, and mass time histories.
6 1 Introduction
Now, we study the first program line by line. The m-script starts with the
command ‘clear’. The clear command removes all variables in the workspace.
In the workspace, there would be some variables defined and used in previous
activities. They may have the same names but different meanings and values in
the current calculation. For example, the gravitational acceleration ‘grv_const’ in
the third line is undefined in the current program and uses a variable of the same
name used to analyse objects falling on the moon. A falling object program in
the Moon was executed earlier, and ‘grv_const’ is still in the workspace. Without
the clear command, the incorrect constant is used in the program producing
wrong results. Hence, it is recommended to clear the workspace before starting
new calculations. We must be careful, however, that the clear command erases
all variables in the workspace. Before the clear command, we check if all values,
which might be generated from a long computer simulation, were saved.
From line 3 to line 12, several constants are defined. Based on the equations we
have seen earlier, it is tempting to write a code as follows:
g = 9.81
x = 0.0
v = 0.5
t = [0 5]
x0 = [ x v m]
These seem to look compact and closer to the equations we derived. It is a bad
habit to write a program in this way. The list of problems in the above programming
style is as follows:
● It defines a variable with a single character, ‘g’, ‘x’, ‘v’, etc. Using a single char-
acter variable might cause confusion on the meaning of the variable and lead to
using them in wrong places with incorrect interpretations.
● Numerical numbers are written without units. There is no indication of units of
the numerical values, e.g. 9.81, is it m/s2 or ft/s2 ?
● It uses magic numbers. What do the numbers, 0 and 5, mean in defining ‘t’?
Program 1.1 uses a better style. The initial position is defined using the variable
name, ‘init_pos’, whose value is 0.0 and the unit is in metres. Appropriately named
variables reduce mistakes and confusion in the program. Program 1.1 indicates the
corresponding unit for each numerical value, e.g. the ‘init mass’ value 5.0 is in kg.
We understand the meaning of each variable by its name. The texts after ‘%’ are
the comments, where we could add various information such as the unit of each
numerical value.
1.2 Motivation Examples 7
In line 13, the built-in Runge–Kutta integrator, ode45(), is used to integrate the
differential equation provided by the function, ‘free_falling_obj’, at the end of the
m-script. Frequently, each function is saved as a separate m-script. It could also
be included in the m-script for the cases that the functions might be used in the
specific m-script only. To include functions in the m-script, they must be placed at
the end of the m-script as in this example.
Functions in Matlab begin with the keyword function and close with the
keyword end. In line 30, ‘dxdt’ is the return variable of the function and
‘free_falling_obj’ is the function name. The function has three input arguments.
A function can have any input argument used by the function. This particular
function, ‘free_falling_obj’, is not an ordinary function, however. This is the
function to describe the ODE. The function is to be passed into the built-in
integrator, ode45. The first two arguments of the function for ode45 must be time
and states, i.e. t and x in (1.6).
In lines 31–33, the variable ‘state’ is assumed to be a three-dimensional vector,
and each element of the vector corresponds to the states, x1 , x2 , and x3 . In line 35,
the return variable ‘dxdt’ is initialized as [0 0 0] by the built-in function zeros(3,1).
zeros(m,n) creates the m × n matrix filled in zeros. Lines 36, 37, and 38 define the
state-space form ODE, (1.6).
The function works perfectly well without the initialization line for ‘dxdt’,
line 35. However, it is not good programming if line 35 is removed. Without the
initialization, ‘dxdt’ in line 36 is a one-dimensional scalar value. In the next lines,
it becomes a two-dimensional value and a three-dimensional value. Each line, the
size of ‘dxdt’ changes, and this requires the computer to find additional memory
to store the additional value. This could increase the total computation time
longer and could be noticeably longer if this function is called a million times or
more. Hence, it is better to acquire all the required memory ahead as in line 35.
It is vital to have the habit of being conscious of the efficiency of algorithm imple-
mentation. On the other hand, try not to overthink the efficiency of the program.
Script languages such as Matlab and Python are for rapid implementation and
testing. Hence, it needs a proper balance between optimizing codes and saving the
development time.
Now, we are ready to solve the differential equation using the built-in numerical
integrator, ode45. ode45 stands for ODE with Runge–Kutta fourth- and fifth-order
8 1 Introduction
When we use ode45, the input argument starts with @ symbol, which is the
function handle. The function handle, @, is used when we pass function A, e.g.
‘free_falling_obj’, to function B, e.g. ode45, where function B would call function
A multiple times. With the function handle, we can control or construct the
function to be passed with some flexibility. ‘@(time,state)’ explicitly indicates
that the function to be passed has two arguments, ‘time’ and ‘state’, and they will
be passed between ode45 and ‘free_falling_obj’ function in the specific order, i.e.
‘time’ be the first and ‘state’ be the second argument. This order is required by the
integrator, ode45.
With the function handle, we can take some freedom to order the function argu-
ments differently in the function definition of ‘free_falling_obj’. For example, we
could write the function as follows:
function d x d t = f r e e _ f a l l i n g _ o b j ( time , g r v _ c o n s t , s t a t e )
x1 = state (1) ;
x2 = state (2) ;
x3 = state (3) ;
d x d t = zeros ( 3 , 1 ) ;
d x d t ( 1 ) = x2 ;
d x d t ( 2 ) = g r v _ c o n s t + ( x3 −2) ∗ ( x2 / x3 ) ;
d x d t ( 3 ) = −x3 + 2 ;
end
and the integration part is updated to follow the updated function definition as
follows:
The program works the same as the ones before the modifications. Also, we
notice that we have an additional input argument, ‘grv_const’. Similarly, we could
add more input parameters if they are necessary. As long as the first argument,
‘time’, and the second argument, ‘state’, are indicated in the function handle, the
function can have any number of input arguments in any order to pass to the
integrator, ode45.
Once the integration is completed, the results return to two output variables,
‘tout’ and ‘xout’. Execute the command, whos, in the Matlab command prompt,
the following information is displayed:
1.2 Motivation Examples 9
>> whos
Name Size Bytes Class Attributes
final_time 1 x1 8 double
grv_const 1 x1 8 double
init_mass 1 x1 8 double
init_pos 1 x1 8 double
init_time 1 x1 8 double
init_vel 1 x1 8 double
time_interval 1 x2 16 double
tout 61 x1 488 double
x0 1 x3 24 double
xout 61 x3 1464 double
The first column shows all variables created including the two output results from
the integrator. The second column shows the size of each variable: ‘tout’ is 61
rows and 1 column and ‘xout’ is 61 rows and 3 columns. Hence, each row of ‘xout’
corresponds to the time instance of the corresponding row values of ‘tout’. Why
is the number of row 61? This is determined by the integrator automatically to
adjust the integration accuracy and computation time. We can assign the number
of rows or the number of time steps explicitly, and this is covered in the later
chapters. The three columns of ‘xout’ correspond to the state, x, x, ̇ and m. The
̇ and the last
first column of ‘xout’ is for x, the second column of ‘xout’ is for x,
column of ‘xout’ is for m.
By executing the following line in the Matlab command prompt, we can print
out all values of x(t) in the command window:
>> x o u t ( : , 1 )
where ‘:’ indicates all rows. If we want to see the values of x from the 11th row to
the 15th row, then
>> x o u t ( 1 1 : 1 5 , 1 )
Similarly, the time history of ẋ is xout(:,2) and the time history of m is xout(:,3).
The plot command in Matlab plots the results as follows:
Before plotting each figure, open a new figure window using figure(1), figure(2),
and figure(3), respectively. The label for each axis is created using the commands
xlabel and ylabel for the horizontal and the vertical axes, respectively, where each
axis must indicate what quantity and what units are used.
10 1 Introduction
On lines 4 through 14, the constants are defined with the proper naming and
the units indicated in the comments. In Python, comments are placed after #.
The first two lines shown are not trivial to understand for the beginners of the
Python language. Python has many packages, and each package is a collection of
functions. There are several different ways to load these functions and the first line
in the program,
shows one of the methods. from and import are the keywords in Python. It loads
the function linspace from the library called numpy. numpy is one of the scien-
tific and engineering libraries and includes many useful functions such as matrix
manipulations, and maths functions.
Numpy vs. scipy: The two packages are very similar and have many common
functions. The execution speed of numpy is faster than scipy; in general, as
numpy is written in C-language while scipy is written in Python. Scipy, how-
ever, has more specialized functions, which are not implemented in numpy.
We might wonder why each function is manually loaded before it is used, unlike
in Matlab. This is one of the design principles of the Python language. If all func-
tions are pre-loaded or they are automatically searched and loaded when they are
used, then the search time or the size of the memory storing the function lists is
long or larger. Hence, it is more efficient to load the functions manually when they
are used.
The function linspace has three input arguments, for example, line 14 generates
an array of numerical values starting from the initial time, 0.0, to the final time,
5.0, whose number of elements is equal to ‘num data’, 100. Unlike the integrator
in Matlab, the Python integrator, discussed shortly later, needs the explicit time
lists as one of the input arguments.
In the second line, the numerical integrator, solve_ivp, is loaded
2 from s c i p y . i n t e g r a t e import s o l v e _ i v p
This is slightly different from the way to load a function shown in the first line.
scipy is another science and engineering function library. Some library divides the
functions in the library into several categories. integrate is one of the categories in
the scipy library. To access the functions under the category, integrate, the period is
used after the library name, i.e. scipy.integrate. The numerical integrator, solve_ivp,
12 1 Introduction
is defined in the integrate category of the scipy library. If we try to load the function
using from scipy import solve_ivp, it cannot find the integrator and generates an
import error.
The ODE are defined between lines 17 and 22. The first line of the function
definition begins with the keyword, ‘def’, the function name, ‘free_falling_obj’,
the three input arguments, and the colon, ‘:’ as follows:
def f r e e _ f a l l i n g _ o b j ( time , s t a t e , g r v _ c o n s t ) :
In general, the function to be defined could have any input arguments. The func-
tion to be passed to solve_ivp, however, must have the first two input arguments,
time and state, in this order. solve_ivp assumes that the first arguments and the sec-
ond argument of the function passed are t and x in ẋ = dx∕dt in (1.6). The main
body of the function is between the line below the function heading and the return
line. Those lines that belong to the main part of the function are indented. The
indentation in Python is not a decoration to simply improve the readability as in
many other programming languages. The indentation in Python is the way to indi-
cate which lines belong to the function body. The following is the first line of the
function body:
x1 , x2 , x3 = s t a t e
where ‘state’ is presumed to have three elements, and they are assigned to the three
new variables on the left-hand side of the equal sign, ‘x1’, ‘x2’, and ‘x3’. Instead of
unpacking the three elements one by one, it unpacks all the three elements in
one line.
‘dxdt’ is the list element in Python. In the list, each element is separated by the
comma, ‘,’. Finally, ‘dxdt’ becomes the return value of the function by the keyword,
return, and the function is passed to the integrator, solve_ivp.
The first input argument of the integrator is the function name describing the
ODE. The second one is the integration time interval. The third one is the initial
condition. ‘t eval’ is the list of time points, where the solution, x(t), is stored to the
output of the integrator. The last one is the arguments, whose name is reserved by
args. As the function ‘free_falling_obj’ has the additional input variable apart from
the time and the state, i.e. ‘grv_const’, this value must be sent to ‘solve_ivp’. args
is the input variable of ‘solve_ivp’ to pass additional input variables. ‘grv const’
is passed to the integrator by ‘arg=(grv const,)’. The data type of args is a tuple.
(1.3, 4.2, 4.3) or (1.3, 2.3) is a tuple. When there is only one element in a tuple, for
example, (1.2,), the comma at the end must not be omitted. (1.2) is interpreted as
floating-point 1.2, not a tuple. To make it a tuple, it must be (1.2,). Hence, there is
the comma after ‘grv const’ in ‘args=(grv const,)’.
1.2 Motivation Examples 13
Similar to Matlab, typing ‘whos’ at the command prompt in Python prints out
the following list to the screen:
The solution of the ODE is stored in ‘sol’, whose type is OdeResult, and it includes
various information about the integration results. Typing ‘sol’ in the command
prompt and hitting enter shows what variables are in ‘sol’. We can access x(t)
through ‘sol.y’. To avoid keep adding the dot to access x(t) inside ‘sol’, create a
new variable, ‘xout’, and store ‘sol.y’ into ‘xout’. We can also see from the variable
̇
list that the size of ‘xout’ is 3 ×100. Each of the rows corresponds to x(t), x(t), and
m(t), respectively.
To plot the results, a plotting library must be loaded. matplotlib is the most
widely used plotting library in Python. More specifically, plot functions under
matplotlib.pyplot category are the most frequently used. Load the functions as
follows:
import m a t p l o t l i b . p y p l o t
The way to access the functions under a specific category is using the dot next to
the package name. matplotlib.pyplot means that we want to access the functions
under the sub-category called pyplot in matplotlib instead of loading all functions
in matplotlib. Now, we can use the plot command in pyplot as follows:
This is inconvenient as the name becomes very long. To reduce the length of the
name, pyplot is loaded as follows:
import m a t p l o t l i b . p y p l o t a s p l t
14 1 Introduction
After the keyword as, any convenient name we would call it could be used. By
convention or almost standard, matplotlib.pyplot is called ‘plt’. Hence, the long
name to call ‘plot’ is shortened to
p l t . p l o t ( tout , xout [ 0 , : ] )
This plots x(t) vs. time t. Unlike Matlab, array indices in Python start at 0, not 1.
The first row of ‘xout’ is ‘xout[0,:]’, the second row of ‘xout’ is ‘xout[1,:]’, and so
forth. xlabel and ylabel commend work the same way as the ones in Matlab.
Ligand (L)
Receptor (R)
Extra-cellular
Cell membrane
Intra-cellular
where kon and koff are the reaction rates of binding or unbinding the receptor and
the ligand, R and L, respectively, to form or destroy the complex, C, the receptor
is destroyed with the rate of kt , the complex is also destroyed with the rate of ke ,
f (t) is the stimulus that produces the ligand at the unit rate, and QR is the internal
receptor generation at the unit rate.
We derive a set of ODE using the molecular interactions. To this end, we intro-
duce the following two assumptions:
● All the molecules and the sources are uniformly distributed in the reaction space
● There are a sufficient number of molecules for every molecular species to con-
sider concentration alone.
The first assumption makes the modelling being ODE. Otherwise, partial differen-
tial equations with the spatial coordinates are solved. Solving partial differential
equations is computationally a lot more challenging than solving ODE. The sec-
ond assumption indicates that the population of each molecular species is far away
from 0. The randomness of molecular interactions and the integer nature of the
number of molecules are ignored in the modelling.
Molecular interactions are stochastic. The probability of the occurrence
of each reaction is calculated in stochastic simulations. We will discuss the
details of stochastic modelling and simulation in the later chapter. On the other
hand, deterministic simulations are performed by assuming a large number
of molecules. The average molecular numbers show deterministic trajectories,
where the random fluctuations are negligible.
Consider the receptor, R, which is directly involved in the three reactions. L
binds to R and becomes C in (1.7a). The concentration of R is decreased by this
reaction. The change rate is proportional to the concentrations of R and L as fol-
lows:
d[R]
∝ −[R] × [L] (1.8)
dt
where [⋅] is the concentration of the molecules. The proportional constant is given
by kon in the reaction. The concentration unit is nanomolar (nM). Molar is equal
to N∕(NA V), where N is the number of molecules, NA is Avogadro’s number equal
to 6.022 × 1023 , and V is the reaction space volume in litres.
In (1.7b), C is decomposed into R and L. The concentration of R is increased
by this reaction. The decreasing rate is proportional to the concentration of C as
follows:
d[R]
∝ [C] (1.9)
dt
where the proportional constant is koff . The receptor is destroyed by itself at the
rate of kt as follows:
d[R]
∝ −[R] (1.10)
dt
16 1 Introduction
1 clear ;
2
3 i n i t _ r e c e p t o r = 0 . 1 ; % [nM]
4 i n i t _ l i g a n d = 0 . 0 4 1 5 ; %[nM]
5 i n i t _ c o m p l e x = 0 . 0 ; %[ kg ]
6
7 i n i t _ t i m e = 0 ; % [ min ]
8 f i n a l _ t i m e = 1 8 0 . 0 ; % [ min ]
9 time_interval = [ init_time final_time ] ;
10
11 kon = 0 . 0 9 7 2 ; % [ 1 / ( min nM) ]
12 k o f f = 0 . 2 4 ; % [ 1 / min ]
13 k t = 0 . 0 2 ; % [ 1 / min ]
14 ke = 0 . 1 5 ; % [ 1 / min ]
15
16 f t = 0 . 0 ; % [nM/ min ]
17 QR = 0 . 0 1 6 6 ; % [nM/ min ]
18 R_max = 0 . 4 1 5 ; %[nM]
19
20 sim_para = [ kon k o f f k t ke f t QR R_max ] ;
21
22 x0 = [ i n i t _ r e c e p t o r i n i t _ l i g a n d i n i t _ c o m p l e x ] ;
23 [ t o u t , x o u t ] = ode45 (@( time , s t a t e ) R L C _ k i n e t i c s ( time , s t a t e , sim_para )
, t i m e _ i n t e r v a l , x0 ) ;
24
25 figure ( 1 ) ; c l f ;
26 subplot ( 3 1 1 ) ;
27 plot ( tout , xout ( : , 1 ) )
28 y l a b e l ( ’ R e c e p t o r [nM] ’ ) ;
29 x l a b e l ( ’ time [ min ] ’ ) ;
30 axis ( [ t i m e _ i n t e r v a l 0 0 . 5 ] ) ;
31 subplot ( 3 1 2 ) ;
32 plot ( tout , xout ( : , 2 ) )
33 y l a b e l ( ’ Ligand [nM] ’ ) ;
34 x l a b e l ( ’ time [ min ] ’ ) ;
35 axis ( [ t i m e _ i n t e r v a l 0 0 . 0 5 ] ) ;
36 subplot ( 3 1 3 ) ;
37 plot ( tout , xout ( : , 3 ) )
38 y l a b e l ( ’ Complex [nM] ’ ) ;
39 x l a b e l ( ’ time [ min ] ’ ) ;
40 axis ( [ t i m e _ i n t e r v a l 0 0 . 0 0 4 ] ) ;
41
42 function d x d t = R L C _ k i n e t i c s ( time , s t a t e , sim_para )
43 R = state (1) ;
44 L = state (2) ;
45 C = state (3) ;
46
47 kon = sim_para ( 1 ) ;
48 k o f f = sim_para ( 2 ) ;
49 k t = sim_para ( 3 ) ;
50 ke = sim_para ( 4 ) ;
51 f t = sim_para ( 5 ) ;
52 QR = sim_para ( 6 ) ;
18 1 Introduction
53 R_max = sim_para ( 7 ) ;
54
55 i f R > R_max
56 QR = 0 ;
57 end
58
59 d x d t = zeros ( 3 , 1 ) ;
60 d x d t ( 1 ) = −kon∗R∗L + k o f f ∗C − k t ∗R + QR ;
61 d x d t ( 2 ) = −kon∗R∗L + k o f f ∗C + f t ;
62 d x d t ( 3 ) = kon∗R∗L − k o f f ∗C − ke∗C ;
63 end
Figure 1.4 shows the simulation results. The receptor concentration increases
almost linearly at the beginning and fluctuates later around the maximum con-
centration limit. The ligand–receptor reaction steadily consumes the ligand when
they bind together and become the ligand–receptor complex. The complex has a
peak concentration that occurred around 20 minutes and then slowly decayed.
Figure 1.5 shows the simulation results of the Python program, Program 1.5.
Unlike the figure commands in Matlab for Figure 1.4, plotting subfigures in mat-
plotlib is not as simple as in Matlab. We need advanced features in matplotlib.
The advanced features of subplots in matplotlib are introduced in detail later in
Program 2.2. As we notice in the figure, the figure fonts are too small to read. How
to adjust the figure font sizes is also discussed in Program 2.2.
Receptor (nM)
0.4
0.2
0
0 20 40 60 80 100 120 140 160 180
Time (min)
0.04
Ligand (nM)
0.02
0
0 20 40 60 80 100 120 140 160 180
Time (min)
× 10–3
4
Complex (nM)
0
0 20 40 60 80 100 120 140 160 180
Time (min)
Figure 1.4 (Matlab) EGFR receptor, ligand, and complex time histories.
Another Random Scribd Document
with Unrelated Content
many respects be well illustrated by their aid. Thus, they may be
employed:—
We then have,—
160
With regard to all the above, it may be said that the use of the
circles gives us nothing that could not easily have been obtained
independently. This is of course true; but no one, who has had
experience of the difficulty that is sometimes found by students in
properly understanding the elementary principles of formal logic, and
especially in dealing with immediate inferences, will despise any
means of illustrating afresh the old truths, and presenting them
under a new aspect.
and here we get the four cases previously given for an I 165
proposition by (a) filling in the dots to the left and striking out those
to the right, (b) filling in all the dots, (c) striking them all out, (d)
filling in those to the right and striking out those to the left.
does not itself represent any proposition, but the framework into
which propositions may be fitted. Denoting not-S by Sʹ and what is
both S and P by SP, &c., it is clear that everything must be contained
in one or other of the four classes SP, SPʹ, SʹP, SʹPʹ ; and the above
diagram shews four compartments (one being that which lies outside
both the circles) corresponding to these four classes. Every universal
proposition denies the existence of one or more of such classes, and
it may therefore be diagrammatically represented by shading out the
corresponding compartment or compartments. Thus, All S is P,
which denies the existence of SPʹ, is represented by
No S is P by
All S is P or Q is represented by
All S is P and Q by
It is in cases involving three or more terms that the advantage of
this scheme over the Eulerian scheme is most manifest. The
diagrams are not, however, quite so well adapted to the case of
particular propositions. Dr Venn (in Mind, 1883, pp. 599, 600)
suggests that we might draw a bar across the compartment declared
to be saved by a particular proposition;173 thus, Some S is P would
be represented by drawing a bar across the SP compartment. This
plan can be worked out satisfactorily; but in representing a
combination of propositions in this way special care is needed in the
interpretation of the diagrams. For example, if we have the diagram
for three terms S, P, Q, and are given Some S is P, 168 we do not
know that both the compartments SPQ, SPQʹ, are to be saved, and
in a case like this a bar drawn across the SP compartment is in some
danger of misinterpretation.
173 Dr Venn’s scheme differs from the schemes of Euler and
Lambert, in that it is not based upon the assumption that our
terms and their contradictories all represent existing classes. It
involves, however, the doctrine that particulars are existentially
affirmative, while universals are existentially negative.
(i) SP SʹPʹ
(vii
SPʹ SʹP
)
173 Comparing the above with the five ordinary Eulerian diagrams
(which may be designated α, β &c. as in section 126), it will be seen
that (i) corresponds to α; (ii) to β; (iii) to γ; (iv) and (v) represent
the two cases now yielded by δ; (vi) and (vii) the two yielded by ε.
Working out the further question how each diagram taken by itself
is to be expressed propositionally we get the following results:
(i) SaP and SʹaPʹ ;
(ii) SaP and SʹoPʹ ;
(iii) SʹaPʹ and SoP ;
(iv) SoP, SoPʹ, SʹoP, and SʹoPʹ ;
(v) SʹaP and SoPʹ ;
(vi) SaPʹ and SʹoP ;
(vii) SaPʹ and SʹaP.
On the same principle and with the aid of dotted lines the four
fundamental propositional forms may be represented as follows:
176 In each case the full extent of a line represents the entire
universe of discourse; any portion of a line that is dotted may be
either S or Sʹ (or P or Pʹ, as the case may be).
This last scheme of diagrams is perhaps more useful than any of
the others in shewing at a glance what immediate inferences are
obtainable from each proposition by conversion, contraposition, and
inversion (on the assumption that S, Sʹ, P, and Pʹ all represent
existing classes). Thus, from the first diagram we can read off at a
glance SaP, PiS, PʹaSʹ, SʹiPʹ ; from the second SeP, PeS, PʹoSʹ, SʹoPʹ ;
from the third SiP and PiS ; and from the fourth SoP and PʹoSʹ. The
last two diagrams are also seen at a glance to be indeterminate in
respect to Pʹ and Sʹ, P and Sʹ, respectively (that is to say, I has no
contrapositive and no inverse, O has no converse and no inverse).
EXERCISES.
132. Illustrate by means of the Eulerian diagrams (1) the relation between A and E, (2)
the relation between I and O, (3) the conversion of I, (4) the contraposition of O, (5) the
inversion of E. [K.]
133. A denies that none but X are Y ; B denies that none but Y are X. Which of the five
class relations between X and Y (1) must they agree in rejecting, (2) may they agree in
accepting? [C.]
134. Take all the ordinary propositions connecting any two terms, combine them in pairs
so far as is possible without contradiction, and represent each combination
diagrammatically. [J.]
CHAPTER VI.