In the provided link, we are given a system with two masses connected by a spring, as shown in the diagram below:
To write the state-space representation of the system, we need to define our state variables. In this case, we can use the positions and velocities of both masses as our state variables:
x1 = position of mass 1
x2 = position of mass 2
x1_dot = velocity of mass 1
x2_dot = velocity of mass 2
Next, we need to write equations that relate the state variables to each other and to the inputs and outputs of the system.
For mass 1, we can use Newton's second law to write:
m1*x1_dot_dot = -k1*x1 + k2*(x2 - x1) + u
where m1 is the mass of mass 1, k1 is the spring constant of the left spring, k2 is the spring constant of the right spring, and u is the input force applied to mass 1.
For mass 2, we can similarly write:
m2*x2_dot_dot = -k3*x2 - k2*(x2 - x1)
where m2 is the mass of mass 2, k3 is the spring constant of the right spring.
We can rearrange these equations to get the second order differential equations for the positions of the masses:
x1_dot_dot = (-k1/m1)
x1 + (k2/m1)(x2 - x1) + (1/m1)*u
x2_dot_dot = (-k3/m2)
x2 - (k2/m2)(x2 - x1)
Now, we can express these second order differential equations as a set of four first order differential equations by introducing our state variables:
x1_dot = x1_dot
x2_dot = x2_dot
x1_dot_dot = (-k1/m1)
x1 + (k2/m1)(x2 - x1) + (1/m1)*u
x2_dot_dot = (-k3/m2)
x2 - (k2/m2)(x2 - x1)
We can then write this set of first order differential equations in matrix form:
where
x = [x1, x2, x1_dot, x2_dot]T is the state vector,
u =
is the input vector,
A is the state matrix:
and B is the input matrix:
Therefore, the state-space representation of the system is:
x_dot = Ax + Bu
y = Cx + Du
where y is the output of the system, which in this case can be chosen as the positions of the two masses:
y = [x1, x2]T
C is the output matrix:
and D is the feedforward matrix:
I hope this helps!