{"id":1744,"date":"2022-02-14T18:23:12","date_gmt":"2022-02-15T02:23:12","guid":{"rendered":"https:\/\/linearcontrol.info\/fundamentals\/?p=1744"},"modified":"2022-03-14T18:25:47","modified_gmt":"2022-03-15T02:25:47","slug":"from-differential-equations-to-state-space-and-beyond","status":"publish","type":"post","link":"https:\/\/linearcontrol.info\/fundamentals\/index.php\/2022\/02\/14\/from-differential-equations-to-state-space-and-beyond\/","title":{"rendered":"From differential equations to state-space and beyond"},"content":{"rendered":"\n<p>We have seen in Chapter 5 how to construct block-diagrams for simulation using integrators and, from there, derive state-space equations. The task was made easier if it was possible to use a chain of integrators, which led to a trivial definition of the state. In many cases that strategy is enough.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>Recall that when you are given a differential equation<br>$$<br>\\ddot{y} + a_1 y + a_2 y = b_2 u,<br>$$<br>in which no derivatives of the input appears or, equivalently, a transfer-function<br>$$<br>G(s) = \\frac{b_2}{s^2+a_1 s+a_2},<br>$$<br>with no zeros, one can calculate relate $y$, $\\dot{y}$ and $\\ddot{y}$ through a chain of integrators, which leads to a state-space realization in which the state vector is comprised of the integrator outputs<br>$$<br>\\begin{pmatrix}<br>x_1 \\\\ x_2 <br>\\end{pmatrix}<br>=<br>\\begin{pmatrix}<br>y \\\\ \\dot{y}<br>\\end{pmatrix}.<br>$$<br>The corresponding simulation block-diagram is in the next figure.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"840\" height=\"315\" src=\"https:\/\/i0.wp.com\/linearcontrol.info\/fundamentals\/wp-content\/uploads\/2022\/02\/chapter5ss.png?resize=840%2C315&#038;ssl=1\" alt=\"\" class=\"wp-image-1748\" srcset=\"https:\/\/i0.wp.com\/linearcontrol.info\/fundamentals\/wp-content\/uploads\/2022\/02\/chapter5ss.png?w=877&amp;ssl=1 877w, https:\/\/i0.wp.com\/linearcontrol.info\/fundamentals\/wp-content\/uploads\/2022\/02\/chapter5ss.png?resize=300%2C113&amp;ssl=1 300w, https:\/\/i0.wp.com\/linearcontrol.info\/fundamentals\/wp-content\/uploads\/2022\/02\/chapter5ss.png?resize=768%2C288&amp;ssl=1 768w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" data-recalc-dims=\"1\" \/><\/figure>\n\n\n\n<p>A state-space representation is obtaining by solving for $\\dot{x}_2 = \\ddot{y}$, as in<br>$$<br>\\dot{x}_2 =\\ddot{y} = -a_1 y &#8211; a_2 y + b_2 u = -a_1 x_1 &#8211; a_2 x_2 + b_2 u<br>$$<br>and observing that<br>$$<br>\\begin{aligned}<br>\\dot{x}_1 &amp;= \\dot{y} = x_2, &amp;<br>y &amp;= x_1.<br>\\end{aligned}<br>$$<br>The complete state-space realization is<br>$$<br>\\begin{aligned}<br>\\begin{pmatrix}<br>\\dot{x}_1 \\\\ \\dot{x}_2<br>\\end{pmatrix}<br>&amp;=<br>\\begin{pmatrix}<br>x_2 \\\\ -a_1 x_1 &#8211; a_2 x_2 + b_2 u<br>\\end{pmatrix}, \\\\<br>y &amp;= x_1.<br>\\end{aligned}<br>$$<br>which can be represented by the standard $A,B,C,D$ matrices as<br>$$<br>\\begin{aligned}<br>\\begin{pmatrix}<br>\\dot{x}_1 \\\\ \\dot{x}_2<br>\\end{pmatrix}<br>&amp;=<br>\\begin{bmatrix}<br>0 &amp; 1 \\\\ -a_1 &amp; -a_2<br>\\end{bmatrix}<br>\\begin{pmatrix}<br>x_1 \\\\ x_2<br>\\end{pmatrix}<br>+<br>\\begin{bmatrix}<br>0 \\\\ b_2<br>\\end{bmatrix}<br>u \\\\<br>y &amp;= \\begin{bmatrix}<br>1 &amp; 0<br>\\end{bmatrix}<br>\\begin{pmatrix}<br>x_1 \\\\ x_2<br>\\end{pmatrix}<br>+<br>0 u.<br>\\end{aligned}<br>$$<\/p>\n\n\n\n<p>The same strategy works for more complex systems, as long as there are no derivatives of the input involved in the equations. For example, the mass-spring-damper system from <strong>P5.26<\/strong> is given by the differential equations<br>$$<br>\\begin{aligned}<br>m_1 \\ddot{z}_1 + (b_1 + b_2) \\dot{z}_1 +<br>(k_1 + k_2) z_1 &#8211; b_2 \\dot{z}_2 &#8211; k_2 z_2 &amp;= 0, \\\\<br>m_2 \\ddot{z}_2 + b_2 (\\dot{z}_2 &#8211; \\dot{z}_1) + k_2 (z_2 &#8211; z_1) &amp;= f_2<br>\\end{aligned}<br>$$<br>Note that if the force $u = f_2$ is the input, then no derivatives of the input appear in these equations. Therefore, one should be able to use a chain of integrators to realize the system. The resulting state is the vector<br>$$<br>\\begin{pmatrix}<br>x_1 \\\\ x_2 \\\\ x_3 \\\\ x_4<br>\\end{pmatrix}<br>=<br>\\begin{pmatrix}<br>z_1 \\\\ \\dot{z}_1 \\\\ z_2 \\\\ \\dot{z}_2<br>\\end{pmatrix},<br>$$<br>and the state-space equations are obtained by solving for the second-order derivatives<br>$$<br>\\begin{aligned}<br>\\dot{x}_2 = \\ddot{z}_1 &amp;= &#8211; \\frac{k_1 + k_2}{m_1} z_1 -\\frac{b_1 + b_2}{m_1} \\dot{z}_1 + \\frac{k_2}{m_1} z_2 + \\frac{b_2}{m_1} \\dot{z}_2, \\\\<br>&amp;= &#8211; \\frac{k_1 + k_2}{m_1} x_1 -\\frac{b_1 + b_2}{m_1} x_2 + \\frac{k_2}{m_1} x_3 + \\frac{b_2}{m_1} x_4, \\\\<br>\\dot{x}_4 = \\ddot{z}_2 &amp;= &#8211; \\frac{k_2}{m_2} (z_2 &#8211; z_1) -\\frac{b_2}{m_2} (\\dot{z}_2 &#8211; \\dot{z}_1) +  \\frac{1}{m_2} u, \\\\<br>&amp;= &#8211; \\frac{k_2}{m_2} (x_3 &#8211; x_1) -\\frac{b_2}{m_2} (x_4 &#8211; x_2) +  \\frac{1}{m_2} u.<br>\\end{aligned}<br>$$<br>If the output is $y = z_2 = x_3$ then<br>$$<br>\\begin{aligned}<br>\\dot{x}_1 &amp;= \\dot{z}_1 = x_2, &amp;<br>\\dot{x}_3 &amp;= \\dot{z}_2 = x_4, &amp;<br>y &amp;= x_1.<br>\\end{aligned}<br>$$<br>Putting it all together<br>$$<br>\\begin{aligned}<br>\\begin{pmatrix}<br>\\dot{x}_1 \\\\ \\dot{x}_2 \\\\ \\dot{x}_3 \\\\ \\dot{x}_4<br>\\end{pmatrix}<br>=<br>\\begin{pmatrix}<br>x_2 \\\\<br>-\\frac{k_1 + k_2}{m_1} x_1-\\frac{b_1 + b_2}{m_1} x_2 + \\frac{k_2}{m_1} x_3 + \\frac{b_2}{m_1} x_4 +  \\\\<br>x_4 \\\\<br>\\frac{k_2}{m_2} x_1 + \\frac{b_2}{m_2} x_2 &#8211; \\frac{k_2}{m_2} x_3 &#8211; \\frac{b_2}{m_2} x_4 + \\frac{1}{m_2} u<br>\\end{pmatrix}<br>\\end{aligned}<br>$$<br>which can be represented by the standard $A,B,C,D$ matrices as<br>$$<br>\\begin{aligned}<br>\\begin{pmatrix}<br>\\dot{x}_1 \\\\ \\dot{x}_2 \\\\ \\dot{x}_3 \\\\ \\dot{x}_4<br>\\end{pmatrix}<br>&amp;=<br>\\begin{bmatrix}<br>0 &amp; 1 &amp; 0 &amp; 0 \\\\<br>-\\frac{k_1 + k_2}{m_1} &amp; -\\frac{b_1 + b_2}{m_1} &amp; \\frac{k_2}{m_1} &amp;  \\frac{b_2}{m_1} \\\\<br>0 &amp; 0 &amp; 0 &amp; 1 \\\\<br>\\frac{k_2}{m_2} &amp; \\frac{b_2}{m_2}  &amp; -\\frac{k_2}{m_2}  &amp; -\\frac{b_2}{m_2} <br>\\end{bmatrix}<br>\\begin{pmatrix}<br>x_1 \\\\ x_2 \\\\ x_3 \\\\ x_4<br>\\end{pmatrix}<br>+<br>\\begin{bmatrix}<br>0 \\\\ 0 \\\\ 0 \\\\ \\frac{1}{m_2}<br>\\end{bmatrix}<br>u \\\\<br>y &amp;= \\begin{bmatrix}<br>0 &amp; 0 &amp; 1 &amp; 0<br>\\end{bmatrix}<br>\\begin{pmatrix}<br>x_1 \\\\ x_2 \\\\ x_3 \\\\ x_4<br>\\end{pmatrix}<br>+<br>0 u.<br>\\end{aligned}<br>$$<\/p>\n\n\n\n<p>Having obtained the state-space matrices $(A,B,C,D)$ one can then use MATLAB or another computer tool to calculate properties of the system. For example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sys = ss(A,B,C,D)<\/code><\/pre>\n\n\n\n<p>creates a state-space system in MATLAB from which one can obtain the poles and zeros of the system with the commands <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pole(sys)\nzero(sys)<\/code><\/pre>\n\n\n\n<p>or the complete transfer-function by the command<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>tf(sys)<\/code><\/pre>\n\n\n\n<p>Note that state-space systems with different outputs can be easily produced by changing the $C$ matrix. For example, the system with output $y = z_1 = x_1$ has the same $A$ and $B$ matrices above and the matrix<br>$$<br>C = \\begin{bmatrix} 1 &amp; 0 &amp; 0 &amp; 0 \\end{bmatrix}.<br>$$ <\/p>\n","protected":false},"excerpt":{"rendered":"<p>We have seen in Chapter 5 how to construct block-diagrams for simulation using integrators and, from there, derive state-space equations. The task was made easier if it was possible to use a chain of integrators, which led to a trivial definition of the state. In many cases that strategy is enough.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false},"categories":[4],"tags":[52,10,13],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/linearcontrol.info\/fundamentals\/index.php\/wp-json\/wp\/v2\/posts\/1744"}],"collection":[{"href":"https:\/\/linearcontrol.info\/fundamentals\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linearcontrol.info\/fundamentals\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linearcontrol.info\/fundamentals\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linearcontrol.info\/fundamentals\/index.php\/wp-json\/wp\/v2\/comments?post=1744"}],"version-history":[{"count":23,"href":"https:\/\/linearcontrol.info\/fundamentals\/index.php\/wp-json\/wp\/v2\/posts\/1744\/revisions"}],"predecessor-version":[{"id":1772,"href":"https:\/\/linearcontrol.info\/fundamentals\/index.php\/wp-json\/wp\/v2\/posts\/1744\/revisions\/1772"}],"wp:attachment":[{"href":"https:\/\/linearcontrol.info\/fundamentals\/index.php\/wp-json\/wp\/v2\/media?parent=1744"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linearcontrol.info\/fundamentals\/index.php\/wp-json\/wp\/v2\/categories?post=1744"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linearcontrol.info\/fundamentals\/index.php\/wp-json\/wp\/v2\/tags?post=1744"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}