How to model state space for complex valued system correctly in SIMULINK (MATLAB)? - Signal Processing Stack Exchange most recent 30 from dsp.stackexchange.com 2019-11-22T14:52:03Z https://dsp.stackexchange.com/feeds/question/53554 https://creativecommons.org/licenses/by-sa/4.0/rdf https://dsp.stackexchange.com/q/53554 0 How to model state space for complex valued system correctly in SIMULINK (MATLAB)? Unknown123 https://dsp.stackexchange.com/users/30792 2018-11-22T18:16:26Z 2018-12-16T19:33:06Z <p>When trying to use the default state-space model block, if there is a <strong>complex number</strong> valued in the matrices, there will be an error</p> <p><a href="https://i.stack.imgur.com/g8dyb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/g8dyb.png" alt="default state-space model block"></a></p> <hr> <p>To resolve that, firstly I need to look at pseudo reference model of state space on the internet <a href="https://i.stack.imgur.com/GmKCd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GmKCd.png" alt="enter image description here"></a></p> <p>Then, create my own state-space block as a new subsystem</p> <p><a href="https://i.stack.imgur.com/gv1kJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gv1kJ.png" alt="enter image description here"></a></p> <p>u is for input<br> y is for output<br> x is the state variable as an output (for sensing use, such as full state feedback)<br></p> <p>And here is the inside</p> <p><a href="https://i.stack.imgur.com/iBsrH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iBsrH.png" alt="enter image description here"></a></p> <hr> <p>Now the problem is that,<br></p> <ol> <li>The <strong>IC (Initial Condition)</strong> block cannot simulate what <strong>lsim</strong> can done in matlab code, there must be an exponential decay expected result for the unforced solution, but what I've got is that the initial condition only happened at the <strong>exact t=0</strong> and there is <strong>no</strong> exponential decay. <br> How do I solve it?</li> <li>The <strong>Integrator</strong> and <strong>IC</strong> block cannot operate with complex valued number, the input and must be separated manually into real and imaginary part or magnitude and phase part and then joined together again. Is there any better way to operate them with complex valued number in simulink?</li> <li>The <strong>gain</strong> block of A, B, C, and D matrix look ugly, I haven't been able to change it in the shape of rectangle box as my reference model above. Is there any way to change it?</li> </ol> <p>Finally, if there is any better solution for my problem, such as pre-builtin complex valued state-space model, or better subsystem, I would be happy to know it</p> https://dsp.stackexchange.com/questions/53554/-/53556#53556 2 Answer by fibonatic for How to model state space for complex valued system correctly in SIMULINK (MATLAB)? fibonatic https://dsp.stackexchange.com/users/7579 2018-11-22T19:12:34Z 2018-12-16T19:33:06Z <p>You can split up the real and imaginary part of the state into their own seperate states. Namely by defining <span class="math-container">$x_r=\mathrm{Re}(x)$</span>, <span class="math-container">$x_i=\mathrm{Im}(x)$</span>, <span class="math-container">$A_r=\mathrm{Re}(A)$</span>, <span class="math-container">$A_i=\mathrm{Im}(A)$</span>, <span class="math-container">$u_r=\mathrm{Re}(u)$</span>, <span class="math-container">$u_i=\mathrm{Im}(u)$</span>, <span class="math-container">$B_r=\mathrm{Re}(B)$</span> and <span class="math-container">$B_i=\mathrm{Im}(B)$</span> then the differential equation can also be written as</p> <p><span class="math-container">$$\dot{x}_r+i\,\dot{x}_i=(A_r+i\,A_i)(x_r+i\,x_i)+(B_r+i\,B_i)(u_r+i\,u_i)$$</span></p> <p>which when split into their real and imaginary part gives</p> <p><span class="math-container">$$\begin{bmatrix} \dot{x}_r \\ \dot{x}_i \end{bmatrix}= \begin{bmatrix} A_r &amp; -A_i \\ A_i &amp; A_r \end{bmatrix} \begin{bmatrix} x_r \\ x_i \end{bmatrix}+ \begin{bmatrix} B_r &amp; -B_i \\ B_i &amp; B_r \end{bmatrix} \begin{bmatrix} u_r \\ u_i \end{bmatrix}.$$</span></p> <p>The output can be expressed using</p> <p><span class="math-container">$$y=C\begin{bmatrix} I &amp; i\,I \end{bmatrix} \begin{bmatrix} x_r \\ x_i \end{bmatrix} + D\begin{bmatrix} I &amp; i\,I \end{bmatrix} \begin{bmatrix} u_r \\ u_i \end{bmatrix}.$$</span></p>