[Math] differential equation into state space

control theoryMATLABordinary differential equations

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?

Best Answer

You have done your calculations correctly and the results are the same. It looks like different because there are infinitely many state space representation of a system, depending on the choice of state variables.

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}$$