# Use of state space equations to model a dynamic system

1. Jul 14, 2009

### Cyclops

Hello,

I enclose a jpeg of the circuit and two simulink jpeg files. The first mdl file - First Test circuit sucessfully models the circuit. The second one where I attempt to model the circuit from its state space equation does not. Can anyone help me to create a correct state space model.

I can only upload jpegs so the mdl file diagrams have been saved as jpegs.

I am aware that matlab has a block for state space equations.

Kind regards,

Cyclops

#### Attached Files:

File size:
6.4 KB
Views:
113
File size:
9.2 KB
Views:
109
• ###### First Test Circuit State Space.JPG
File size:
12.8 KB
Views:
116
2. Jul 14, 2009

### trambolin

The second one is already in a state space form. What do you mean by remodeling from State space again?

3. Jul 15, 2009

### Cyclops

Dear Trambolin,

I am trying to obtain the circuit circuit by both methods. The two outcomes should be the same in matlab and they are not. The state variable for circuit current is x1 in my working out shown in PDF.
I enclose a zip file with two simulink files and a pdf which shows my working out.

Kind regards,

Kieran A. Murray

#### Attached Files:

• ###### QuestiontoPhysicsForum.pdf
File size:
341.8 KB
Views:
75
File size:
11.1 KB
Views:
65
4. Jul 15, 2009

### trambolin

cyclops,

I tried to understand what you try to ask but it doesn't makes sense to me. I would start from your integro-differential equation and define my states as $$\int{i(t)dt} = x_1(t), i(t) = x_2(t)$$

Then the rest is basically the same, I have to say that state space representation is nothing but a first order ODE version of the very same equations. I mean,

\begin{align*} \dot x_1(t) & = x_2(t)\\ \dot x_2(t) & = \frac{1}{L}\left( \frac{-1}{C}x_1(t) - Rx_2(t) + V_s\right) \end{align*}

If you convert them to matrix notation,

$\begin{pmatrix}\dot x_1\\\dot x_2\end{pmatrix} = \begin{bmatrix}0 &1\\-\frac{1}{LC} &-\frac{R}{L}\end{bmatrix} \begin{pmatrix}x_1\\x_2\end{pmatrix}+ \begin{bmatrix}0 \\\frac{1}{L}\end{bmatrix}V_s$

Then if you want to observe the current which is our second state you define your output matrix as

$y = \begin{bmatrix}0 &1\end{bmatrix}\begin{pmatrix}x_1\\x_2\end{pmatrix}$

5. Jul 15, 2009

### Cyclops

Dear trambolin,

How do you implement the observation of the current in Matlab using integrators for the state space equation. The result should be the same as for the first circuit First circuit.mdl which observes the current by solving directly from the integro-differential equation. When I tried to implement this in my state space solver the solution was NOT the same. Running both simulations should give the same result as viewed in the Scope. It does not.

6. Jul 16, 2009

### trambolin

Yes but I wish I could understand what you did in the second case. I don't understand what you mean as a state space method. What I did is also state space method. Why don't you like it?

Can you type it at least to reduce the handwriting confusion? Also the initial conditions of the integrators was not the same...

7. Jul 16, 2009

### Cyclops

Dear trambolin,

Using your equations, the state variable x2 is the inductor current in the circuit. I am trying to use integrators to solve the first order differential equation represented by the bottom line of your state space equation. This does not seem to work as it gives a different result to the second order differential equation that is obtained for the inductor current if we start from an integro-differential equation. The equations are correct. My implementation in matlab using integrators to solve the equation for the inductor current using the state space method must be wrong as it gives a different answer to the integrator solution based on the integro-differential equations which I got from a book. I will send workings later on a pdf.

Kind regards,

Kieran A. Murray

8. Jul 19, 2009

### Cyclops

Dear Trambolin,

I have shown all my workings for the equations on a document herein inclosed. Your state space equations create two first order equations from a second order equation. Using the state variables as inductor current and capacitor voltage should also be correct because as far as I understand the basis of this technique is to describe the energy of a system and you will need capacitor voltage and inductor current to do this. I have shown the outputs from matlab and they are different for the same thing - circuit current.

Kind regards,

Cyclops

#### Attached Files:

• ###### Workings for solving current in a circuit.doc
File size:
96.5 KB
Views:
94
9. Jul 20, 2009

### Cyclops

Dear Trambolin,

After a couple of hours work this weekend and another go at it this morning I have come up with some sort of matlab state space model which will give the same output as the matlab integro-differential model. Thanks for your help as it always helps to have someone to work off and you confirmed that I was not completely on the wrong track. Having said that, there was a basic error in my equations as in the integro-differential part I divided across by the differentiator operation and for the step function I came out with 1 which of course is wrong. I include the two diagrams of the matlab files and I will update my workings later if anyone is interested. I intend to give this state-space thing a bit of a bash and so I might have more queries in future. Thanks for your help

The output from both models is the capacitor voltage. The zip file contains both models.

Kind regards,

Cyclops

File size:
17.8 KB
Views:
69