Specifications
4 Designing Controllers Using the Command Line
4-16
Animation of the Multi-Model Example
In order to achieve its objective, the controller can adjust the applied force magnitude
(the length of the red arrow). It receives continuous feedback on the M
1
location. There is
also a contact sensor to signal collisions. The M
2
location is unmeasured.
If M
1
were isolated, this would be a routine control problem. The challenge is that the
relationship between the applied force and the M
1
movement changes dramatically when
M
2
attaches to M
1
.
The following code defines the model. First define the system parameters as follows:
%% Model Parameters
M1=1; % mass
M2=5; % mass
k1=1; % spring constant
k2=0.1; % spring constant
b1=0.3; % friction coefficient
b2=0.8; % friction coefficient
yeq1=10; % wall mount position
yeq2=-10; % wall mount position
Next define a model of M
1
when the masses are separated. Its states are the M
1
position
and velocity. Its inputs are the applied force, which will be the controller's manipulated