Problem Set 8

ENGR 12, Spring 2026.

Due Date Thu, Mar 26
Turn in link Gradescope
URL emadmasroor.github.io/E12-S26/Homework/HW8

Points Distribution

Please note that each of the following grade items is a single rubric item. Each rubric item is scored on a four-level scale of 3-2-1-0. You may wish to take this into account when deciding how to allocate your efforts to each problem.

Problem % Weightage
Problem 1 20
Problem 2 40
Problem 3 40

1 Deriving the equations

Draw correct free-body diagrams and find the governing differential equation(s) for the following system. There should be three second-order differential equations for \(x_1\), \(x_2\) and \(x_3\). Assume that all three lengths are defined such that, when \(x_1=x_2=x_3=0\), there is no restoring force in any of the springs.

Warning

Don’t forget the gravity term!

2 Two Masses on a moving cart

Consider the system shown below, in which two masses \(M_1\) and \(M_2\) are placed on a moving cart with mass \(M_3\). There is friction between the masses and the cart, following the usual ‘element law’ of friction being proportional to the relative velocity between the two surfaces. A force is applied to mass \(M_1\) to the right with magnitude \(f_a(t)\).

Two masses are connected to each other and to a cart with springs.

2.1 State Variables

Determine the number of state variables in this system and write down mathematical symbols for each of them.

2.2 Input Force

For this part, assume that the cart is forced to be at rest at all times and \(x_3(t) = \dot{x}_3(t) = \ddot{x}_3(t) = 0\). The system is put into motion through a force \(f_a(t)\). Ignore initial conditions.

  1. Draw all relevant free-body diagrams for this system. Your diagrams should have the correct arrows, labels, and signs.
  2. Write down the governing differential equations for this system.
  3. Using the state variables that you identified in Section 2.1 or a subset of them, write down the governing differential equations for this system in the form \(\dot{x} = A \ x + b\), where \(x\) is a vector of state variables, \(A\) is the system matrix, and \(b\) contains information about the applied force.
  4. Use MATLAB to solve this system of equations numerically for an applied force \(f_a(t)\) that is given by the ‘top-hat function’ from HW 7. Generate a plot of the resulting solution and turn in a copy of the modified file prob12_rhs.m (in the form of a screenshot or text, not a .m file) as well as an image of the plot. Note that the system should start from rest. You may make use of the skeleton code provided below. The only significant change that you need to make is in the file named prob12_rhs.m. The parameter values are:
  • \(m_1=m_2 = 1\)
  • \(k_1=k_2=2\)
  • \(b_1=b_2=0.5\)
  1. Repeat the MATLAB solution with a different value for \(k_1 = 10\), keeping all other parameters the same. Turn in the resulting plot.

The input as a function of time looks like the following figure:

Sample Code

TipAnonymous Functions

You may notice that the ‘right hand side’ is provided to ode45 in the code below using some strange notation. The following code makes use of something known as anonymous functions and structs, which are both features of MATLAB and many other programming languages. It is not important to know how anonymous functions work for the purpose of this class.

Anonymous functions help us pass parameters to a function so that we can make use of quantities like \(m\) and \(k\) inside the function without having to explicitly declare them. Structs help to “pack” many variables inside a single variable while preserving names. You could achieve the same result by using a vector of values, but those don’t come with names and you would have to remember which quantity is at which location in the vector.

prob12_rhs.m
function dydt = prob12_rhs(t,y,params)
% r.h.s. of ode for problem 1.2 with applied force.

k1 = params.k1;
k2 = params.k2;
m1 = params.m1;
m2 = params.m2;
b1 = params.b1;
b2 = params.b2;

fa = @(t) + heaviside(t-2).*5.*(t-2) + ...
          - heaviside(t-4).*5.*(t-4) + ...
          - heaviside(t-10).*5.*(t-10) + ...
          + heaviside(t-12).*5.*(t-12);

dydt = [0;0;0;0];
end
% set parameters

params.m1 = 1;
params.m2 = 1;
params.k1 = 2;
params.k2 = 2;
params.b1 = 0.5;
params.b2 = 0.5;

init = [0;0;0;0];
tspan = [0,30];

[t,y] = ode45(@(t,y) prob12_rhs(t,y,params),tspan,init);

x1 = y(:,1);    % x1 is the first column of y
x2 = y(:,3);    % x2 is the third column of y

v1 = y(:,2);
v2 = y(:,4);

figure(1);
clf;
plot(t,x1,"LineWidth",2); hold on;
plot(t,x2,"LineWidth",2);
legend("x1","x2");
title("Response to applied force")
grid on; grid minor;

The result of your numerical solution should look approximately like the graph shown below.

2.3 Input displacement

For this part, we no longer apply a force to \(M_1\) and therefore set \(f_a(t)=0\). Motion is imparted to the system by imposing a kinematic motion \(x_3(t)\) to the cart. Here, \(x_3(t)\) is some known function of time, whose derivatives can also be calculated and therefore are also known functions of time.

  1. Re-write the governing equations for this system under the given conditions.
  2. Write the new governing equations in the form \(\dot{y} = A y + b\), where \(y\) is a vector containing \([x_1, \dot{x}_1, x_2, \dot{x}_2]\) and \(b\) is a vector containing the ‘inputs’.
  3. Write down an expression for the force that would have to be applied to \(M_3\) (in the right-ward direction) to bring about the same motion as that brought about by the given displacement \(x_3(t)\). Note that this expression will contain some terms that are already known, and some terms that, while not explicitly known, have a corresponding differential equation available.

3 Mass hanging on inclined plane

Two masses are connected to each other with an ideal pulley. One of them is on a friction-full inclined plane while the other rests on friction-less wheels. The coordinates \(x_1\) and \(x_2\) are measured relative to some fixed locations, which have been chosen such that when \(x_1 = x_2 = 0\), there is no tension or compression in the springs. A force \(f_a(t)\) is applied to the inclined mass as shown.

3.1 Free body diagrams

Draw the free body diagrams for this system.

3.2 Governing Equations

Write down two second-order differential equations for the motion of this system.

3.3 Equilibrium value

Under gravity alone (i.e., \(f_a(t) = 0\)), this system won’t naturally stay at \(x_1=x_2=0\). Instead, it will settle to some equilibrium value. Determine mathematical expressions for the equilibrium value of \(x_1\) and of \(x_2\), in terms of the parameters given in the problem and \(g\), the acceleration due to gravity..

If the system is initialized with \(x_1 = x_2 = \dot{x}_1 = \dot{x}_2 = f_a(t)=0\), the values of \(x_1\) and \(x_2\) follow the graph shown below. The property values used are shown in the table below.

Table 1: Ignore Units
Parameter Quantity
\(m_1\) 1
\(m_2\) 3
\(b_1\) 2
\(b_2\) 1
\(k_1\) 5
\(k_2\) 10
\(\theta\) \(30^{\circ}\)
Figure 1

3.4 Block Diagram

Make a block diagram for this system. In your block diagram, gather the terms related to gravity and the terms related to the applied force \(f_a(t)\) in a single arrow, which you should show as an input to your system.