trim
Find a steady-state operating point of an nflow model.
📝Syntax
[x, u, y, dx] = trim(model)
[x, u, y, dx] = trim(model, x0, u0)
📥Input Arguments
Parameter Description
model a loaded system (name or handle) or the path to a .nflow file.
x0 optional starting continuous state (length nx) for the search.
u0 optional fixed inputs (length nu). External-port Label Source blocks.
📤Output Arguments
Parameter Description
x the equilibrium continuous state.
u the inputs at the solution (equal to u0).
y the outputs at the solution.
dx the state derivative at the solution; its norm measures how close to equilibrium.
📄Description

trim finds a steady-state (equilibrium) operating point of model: a continuous state x at which xdot = f(x, u0) = 0 for the fixed inputs u0.

It solves the equation by a Newton iteration on the state Jacobian A = d(xdot)/dx computed by linmod, starting from x0. For a linear model the equilibrium is x = -A\(B*u0), reached in one step.

💡Examples
Equilibrium of a first-order state-space model
d.blocks = { ...
  struct('id','u','type','labelSource','inputs',0,'outputs',1,'params',struct('label','u','isExternalPort',true)), ...
  struct('id','ss','type','stateSpace','inputs',1,'outputs',1,'params',struct('A',-2,'B',1,'C',1,'D',0)), ...
  struct('id','y','type','labelSink','inputs',1,'outputs',0,'params',struct('label','y')), ...
  struct('id','sc','type','scope','inputs',1,'outputs',0,'params',struct()) };
d.connections = { ...
  struct('from','u','to','ss','fromIndex',0,'toIndex',0), ...
  struct('from','ss','to','y','fromIndex',0,'toIndex',0), ...
  struct('from','ss','to','sc','fromIndex',0,'toIndex',0) };
f = [tempdir(), 'trim_demo.nflow'];
fid = fopen(f,'wt'); fwrite(fid, jsonencode(d)); fclose(fid);
[x, u, y, dx] = trim(f, 0, 2)  % x = 1 (xdot = 0)
🔗See Also
linmodsim
Used Functions
linmod
🕔Version History
Version Description
1.0.0 initial version
Edit this page on GitHub