# differential equation into state space

I have this dynamic system

$$J \ddot{\theta} + F\dot{\theta} = u$$

I would like to acquire the state space of the system. This is what I've done $$x_{1} = \theta, \\ x_{2} = \dot{\theta}, \\ x_{3} = \ddot{\theta} \\ \dot{x_{1}} = x_{2} \\ \dot{x_{2}} = \ddot{\theta} = \frac{1}{J}u - \frac{F}{J} x_{2} \\ \begin{bmatrix} \dot{x_{1}} \\ \dot{x_{2}} \end{bmatrix} = \underbrace{ \begin{bmatrix} 0 & 1 \\ 0 & -\frac{F}{J} \end{bmatrix}}_{A} \begin{bmatrix} x_{1} \\ x_{2} \end{bmatrix} + \underbrace{ \begin{bmatrix} 0 \\ \frac{1}{J} \end{bmatrix}}_{B} u$$

Is it correct? I've tried to double check my work using Laplace transform. $$G = \frac{Y(s)}{U(s)} = \frac{1}{J s^{2} + Fs}$$

This is the code

>> syms J F
>> b = 1;
>> a = [J, F, 0];
>> [A, B, C, D] = tf2ss(b,a)

A =
[ -F/J, 0]
[    1, 0]

B =
1
0
C =
[ 0, 1/J]
D =
0


Are the results same? Why B in Matlab has no 1/J?

• There is no real point in keeping $x_1$ around. Just use $\dot{\theta}$ as the state variable. – copper.hat Aug 17 '14 at 3:21
• I am ignorant in tf/ss terminology, but I can say that your system for $\dot x_1,\dot x_2$ is correct. I wonder why $Y(s)=1$ is the correct choice. Maybe $Y(s)=J$ should be used? (I don't see any explicit output variable here to begin with...) – user147263 Aug 17 '14 at 6:23
• @900sit-upsaday, why $Y(s) = 1$? who said so? This is ratio. take the Laplace transform of the differential equation (i.e. $J s^{2} Y(s) + F s Y(s) = U(s)$ and get the ratio of the output to the input (i.e. $Y(s)/U(s)$). – CroCo Aug 18 '14 at 15:01
• @copper.hat, actually there is no need for $x_{3}$ not $x_{1}$. the latter represents the angular position which is kind of suitable to name it so that once we get the solution, we can plot it with respect to time. – CroCo Aug 18 '14 at 15:18
• Well, you can solve the single dimensional system in $\dot{\theta}$ and then integrate to get a solution. – copper.hat Aug 18 '14 at 15:20

However, your state space representation is incomplete. Because your system does not have an "output" where you can select a linear combination of the states, using a $C$ matrix, i.e. $y=Cx$.
You can put $1/J$ to either $B$ or $C$ matrix. It is the difference between your transfer function and
$$\frac{1/J}{s^2+(F/J)s}$$
• I can get the solution of the system with no need of $C$. So, $\dot{x} = Ax + Bu$ is enough to acquire the solution. $x(t) = e^{At}x_{o} + e^{At} \int_{t_{o}}^t e^{A \tau} B u (\tau) d \tau$. This is because $A$ is time-invariant. With the results that I got, the angular velocity approaches zero when the time goes to infinity. It seems my solution is correct. – CroCo Aug 18 '14 at 15:11
• You get the solution of "states" not "outputs". In the transfer function you implicitly select the state $x_2$ as output, i.e. $C=\begin{bmatrix}0 & 1\end{bmatrix}$. You could select a different output, like the angle itself. Then your transfer function would be different while state solution is the same. – obareey Aug 18 '14 at 15:52