In the state space representation, the state equation for a linear time-invariant system is:
$$ \dot{\mathbf{x}}(t) = \mathbf{A}\mathbf{x}(t)+\mathbf{B}\mathbf{u}(t) $$
This state equation can be derived by decomposing an $n^{th}$ order differential equation into $n$ first-order differential equations and then choosing the state variables $x_1(t),x_2(t),...,x_n(t)$ and their derivatives $\dot{x}_1(t),\dot{x}_2(t),...,\dot{x}_n(t)$. The state equation essentially describes the relationship between the state variables and the inputs in $\mathbf{u}(t)$.
Additionally, the output equation for a linear time-invariant system is:
$$ \mathbf{y}(t) = \mathbf{C}\mathbf{x}(t)+\mathbf{D}\mathbf{u}(t) $$
However, I am not sure how this output equation is derived. More precisely, what is an "output"? Is it the set of state variables and inputs that need to be observed by the engineer or another system downstream? If that is true, then if I have a mass-spring-damper system, where the displacement of the mass is represented by the state variable $x_1(t)$, the velocity of the mass is represented by the state variable $x_2(t)$, and an externally applied force on the mass is represented by the input variable $u_1(t)$, and I was interested in observing/measuring the displacement of the mass, would my output equation then be:
$$ y(t) = x_1(t) $$
Alternatively, if I was interested in observing both the displacement of the mass and the externally applied force, then would my output equation be:
$$ \mathbf{y}(t) = \begin{bmatrix} y_1(t) \\ y_2(t) \end{bmatrix} = \begin{bmatrix} x_1(t) \\ u_1(t) \end{bmatrix} $$
So far, neither the state variables nor the inputs have been scaled in my output equation. Because of this, I don't understand the purpose of the $\mathbf{C}$ and $\mathbf{D}$ matrices. Could they be used to linearly transform the state variables and inputs for another system downstream? From this image on a typical state space representation:
$\hskip2in$
It seems that what I am saying is correct, but I would prefer a better explanation.