MATLAB Examples

Linearization of a Conveyor Model

This example shows the use of the operating point search and snapshot features along with the linearization of a Simscape Multibody model. (Requires Simscape Multibody)


Operating Condition Search

Open the model.


The steady state operating point can now be found using the operating specification object initialized using the simulated operating point. For the steady state operating point search, the Analysis Type for the Simscape Multibody machine must be set to be in Trimming mode. See the Simscape Multibody documentation for details on this feature.

set_param('scdmechconveyor/Mechanical Environment','AnalysisType','Trimming')
opspec = operspec('scdmechconveyor');

For Simscape Multibody models, the operating condition search in some cases can converge to a steady state condition more quickly using a nonlinear least squares algorithm. This algorithm is available if the Optimization Toolbox is licensed. An iterative report of the search can also be displayed by using the LINEARIZEOPTIONS command.

opt = findopOptions('OptimizerType','lsqnonlin','DisplayReport','none');
opt.OptimizationOptions.MaxFunEvals = 2000;

To ensure that the algebraic constraints in the Simscape Multibody model are met, the trim output port must be specified to be zero.

opspec.Outputs.y = zeros(8,1);
opspec.Outputs.Known = ones(8,1);

The steady state operating point can now be found using the FINDOP command.

[op,opreport] = findop('scdmechconveyor',opspec,opt);

Display the final report.

 Operating point search report for the Model scdmechconveyor.
 (Time-Varying Components Evaluated at time t=0)

Operating point specifications were successfully met.
(1.) scdmechconveyor/Position Controller/H_inf Controller
      x:         -1.08      dx:     -1.42e-14 (0)
      x:     -7.64e-12      dx:     -2.32e-12 (0)
      x:         0.199      dx:     -2.08e-13 (0)
      x:         0.199      dx:      -1.3e-14 (0)
      x:        0.0743      dx:      1.42e-13 (0)
(2.) scdmechconveyor/Position Controller/Loopshaping Weight
      x:      2.59e-07      dx:       3.4e-14 (0)
      x:      2.59e-07      dx:      3.69e-15 (0)
      x:      9.66e-08      dx:     -3.84e-14 (0)
(3.) scdmechconveyor/Position Controller/Prefilter
      x:        0.0103      dx:      2.44e-13 (0)
(4.) scdmechconveyor/Position Controller/inv(W)
      x:     -2.59e-07      dx:      -3.4e-14 (0)
      x:     -2.59e-07      dx:     -3.69e-15 (0)
      x:     -9.66e-08      dx:      1.07e-13 (0)
(5.) Prismatic.P1.Position
      x:         0.103      dx:     -5.01e-21 (0)
(6.) Prismatic.P1.Velocity
      x:     -5.01e-21      dx:      2.89e-13 (0)
(7.) Revolute.R1.Position
      x:        -0.881      dx:      2.52e-21 (0)
(8.) Revolute.R1.Velocity
      x:      2.52e-21      dx:      -2.4e-12 (0)
(9.) Revolute1.R1.Position
      x:          0.83      dx:     -1.06e-20 (0)
(10.) Revolute1.R1.Velocity
      x:     -1.06e-20      dx:      2.22e-12 (0)
(11.) Revolute3.R1.Position
      x:        -0.172      dx:      1.68e-20 (0)
(12.) Revolute3.R1.Velocity
      x:      1.68e-20      dx:     -4.64e-13 (0)
(13.) Revolute5.R1.Position
      x:       0.00175      dx:     -2.39e-22 (0)
(14.) Revolute5.R1.Velocity
      x:     -2.39e-22      dx:     -6.45e-14 (0)

Inputs: None 

(1.) scdmechconveyor/MSB Trimming Out
      y:     -2.31e-13    (0)
      y:      1.41e-13    (0)
      y:     -9.12e-13    (0)
      y:       1.6e-13    (0)
      y:        -5e-21    (0)
      y:      8.91e-22    (0)
      y:      3.01e-21    (0)
      y:       3.9e-21    (0)

Before linearization of the model can be completed, the Analysis Type for the Simscape Multibody model needs to be restored.

set_param('scdmechconveyor/Mechanical Environment','AnalysisType','Forward dynamics')

Linearize the Model

In this model the open loop plant model between the conveyor position and the torque command can be found using the following input and outputs:

io(1) = linio('scdmechconveyor/Joint Sensor',1,'openoutput');
io(2) = linio('scdmechconveyor/Position Controller',1,'input');

Linearize the model.

sys = linearize('scdmechconveyor',op,io);

View the linearized model and corresponding Bode plot.

sysm = zpk(sys)
sysm =
  From input "Torque" to output "Joint Sensor":
  (s-3.481) (s+3.481)
Continuous-time zero/pole/gain model.

Close the model.