E12 Linear Physical Systems Analysis
February 26, 2026
Consider \(m\ddot{x} + kx = 0\).
One choice of state variables is \(x\) and \(\dot{x}\), position and velocity. \[ \frac{d}{dt} \begin{bmatrix} x \\ \dot{x} \end{bmatrix} = \begin{bmatrix} \dot{x} \\ -(k/m)x \end{bmatrix} = \begin{bmatrix} 0 & 1 \\ -k/m & 0 \end{bmatrix} \begin{bmatrix} x \\ \dot{x} \end{bmatrix} \]
Another choice of state variables is \(x\) and \(m \dot{x}\), position and momentum. What would the above equations be with these as the state variables instead? \[ \frac{d}{dt} \begin{bmatrix} x \\ m\dot{x} \end{bmatrix} = \begin{bmatrix} ? \\ ? \end{bmatrix} = \begin{bmatrix} ? & ? \\ ? & ? \end{bmatrix} \begin{bmatrix} x \\ m\dot{x} \end{bmatrix} \]
\[ \frac{d}{dt} \begin{bmatrix} x \\ m\dot{x} \end{bmatrix} = \begin{bmatrix} \dot{x} \\m \ddot{x} \end{bmatrix} = \begin{bmatrix} \dot{x} \\ - k x \end{bmatrix} = \begin{bmatrix} 0 & 1/m \\ -k & 0 \end{bmatrix} \begin{bmatrix} x \\ m\dot{x} \end{bmatrix} \]
The rest length \(l_0\) of a spring is the length at which it exerts no force. It’s neither compressed nor extended.
Note: Our springs are always ‘bidirectional’:

Write down Newton’s 2nd Law for this mass (FBD)
\[m \ddot{x} = f - k (x-l_0)\] \[m \ddot{x} + kx = f + k l_0 \] Let’s say \(f=0\)

The term \(k l_0\) acts like a constant force, i.e., like a step function input

\[m \ddot{x} = f - k (x-l_0)\] \[m \ddot{x} + kx = f + k l_0 \]

\[x_n = x - l_0\] \[\ddot{x}_n = \ddot{x}\] \[m \ddot{x}_n = f - k x_n\] \[m \ddot{x}_n + kx_n = f\]
We use the word ‘order’ to refer to two different things.
What is the order of this system?
Draw free-body diagrams for both systems and write Newton’s laws for each
Count the number of energy-storing elements
\[ \begin{aligned} m_1 \ddot{x}_1 &= \phantom{-}k(x_2-x_1 - l_0) \\ m_2 \ddot{x}_2 &= -k(x_2-x_1-l_0) \\ \end{aligned} \]
\[ \begin{aligned} m_1 \ddot{x}_1 &= \phantom{-}k(x_2-x_1 - l_0) \\ m_2 \ddot{x}_2 &= -k(x_2-x_1-l_0) \\ x_1(0) &= 0, \dot{x}_1(0) = 0.5, x_2(0) = 0.4, \dot{x}_2(0) = 0 \\ m_1 &= m_2 = 1, k = 5, l_0 = 0.7 \end{aligned} \]


ode45 to model higher-order systemsMATLAB’s ode45 can be used to model second-order systems
\[m \ddot{x} + k x = 0 \implies \ddot{x} = -\frac{k}{m} x\]
function dydt = rhs(t,y)
% Implements the right-hand-side of the equation
% dy/dt = f(y,t)
% where y is a vector containing n state variables.
% Here, we are interested in the equation m x'' + k x = 0
% So y1 = x and y2 = x'.
% un-pack contents of y
y1 = y(1);
y2 = y(2);
% define constants
k = 5; m = 3;
% Define what dy/dt is
dy1dt = y2;
dy2dt = -(k/m)*y1;
% Assemble contents of dy/dt into a column vector
dydt = [dy1dt;dy2dt];
endode45 to model higher-order systemsIf the function includes an input, MATLAB expects to incorporate this into the ‘right-hand side function’.
function dydt = rhs(t,y)
% Implements the right-hand-side of the equation
% dy/dt = f(y,t)
% where y is a vector containing n state variables.
% Here, we are interested in the equation m x'' + k x = cos(2t)
% So y1 = x and y2 = x'.
% un-pack contents of y
y1 = y(1);
y2 = y(2);
% define constants
k = 5; m = 3;
% Define what dy/dt is
dy1dt = y2;
dy2dt = -(k/m)*y1 + cos(2*t);
% Assemble contents of dy/dt into a column vector
dydt = [dy1dt;dy2dt];
endode45ode45 takes time.% Use ode45 from t = 0 to t = 10. Initial conditions are
% x(0) = 1, x'(0) = 0
[t,ysol] = ode45(@rhs,[0,10],[1;0]);
% Make plot in one go
plot(t,ysol); % Plots both columns of 'ysol' in one go
% Make plot in n steps, where n = number of state variables
plot(t,ysol); % Plots both columns of 'ysol' in one go
legend("x","x dot","Location","southeast");ode45 to spring-mass systemIn-class activity: For each of the following scenarios, use MATLAB to plot graphs of position and velocity.
Download code from Website > Resources > Numerically Solving Initial Value Problems > Higher Order https://emadmasroor.github.io/E12-S26/Resources/numsol/higherorder
\[ \frac{d}{dt} \begin{bmatrix} y_1 \\ y_2 \\ y_3 \\ y_4 \end{bmatrix} = \begin{bmatrix} 0 & 1 & 0 & 0 \\ -(k_1+k_2)/m_1 & 0 & k_2/m_1 & 0 \\ 0 & 0 & 0 & 1 \\ k_2/m_2 & 0 & -k_2/m_2 & 0 \end{bmatrix} \begin{bmatrix} y_1 \\ y_2 \\ y_3 \\ y_4 \end{bmatrix} + \begin{bmatrix} 0 \\ f_1/m_1 \\ 0 \\ f_2/m_2 \end{bmatrix} \]
\[\dot{\boldsymbol{y}} = \boldsymbol{A} \boldsymbol{y} + \boldsymbol{B} \boldsymbol{u}\]
Note:
E12 • Spring 2026 • Lecture 12 • February 26, 2026