FUNCTION REFERENCE
sim
Simulate an identified model.
Simulate an identified model.
Syntax
y = sim(sys, data)Syntax
y = sim(sys, u)Zero-initial-state response of the measured dynamics. With iddata input the result is an iddata object with the simulated OutputData; with a numeric input vector (discrete models) a column vector.
Example
sim(idpoly([1 -0.5],[0 1]), [1;0;0]) % [0; 1; 0.5]Differences from MATLAB: no noise, initial-condition or option arguments; single input and output.
Neural network form: y = sim(net,x), equivalent to net(x). Configure the network first. Matrix columns are samples; cell sequences return cell sequences.
Example
n = configure(fitnet(2),[0 1],[0 1]); y = sim(n,[0 1]);MPC form: simulate an mpc object using the existing mpcmove controller and the discretized simulation plant.
Syntax
[y,t,u,xp,xmpc,options] = sim(c,T,r[,v][,options])T is a positive integer count of stored samples, at most 65536; t=(0:T-1)'*c.Ts. There are T-1 plant transitions. y is T-by-Ny (physical output order), u is T-by-Nmv (requested MVs, excluding input noise), and xp is T-by-Nxp (physical states before each transition). y excludes OutputNoise. No-output calls draw outputs and MVs in two subplots; requesting any output suppresses plotting. At most six outputs.
r has physical output columns; v has measured disturbance columns. Signals hold their last row. Empty r/v use controller nominal Y/MD input offsets. With lookahead off, the current row is held over the horizon; RefLookAhead='on' passes p reference rows starting at the current sample and MDLookAhead='on' passes p+1 disturbance rows, holding the final available row.
xmpc is a T-by-1 struct array with Plant, Disturbance, Noise, LastMove and Covariance. Each snapshot is taken after mpcmove: Plant is the observer's next prior, LastMove is the current requested MV. Snapshots are independent values; open-loop xmpc is an empty 0-by-1 struct array.
Example
c=mpc(ss(.8,.2,1,0,.1)); [y,t,u,xp,xc,o]=sim(c,3,1); size(y)Differences from MATLAB: MPC supports the mpc object only, fixed controller weights/constraints, and matching physical signal groups for mismatch plants. Discrete mismatches must already use c.Ts. Controller histories are limited to 13107 samples by struct storage; workspace limits also apply.
Reference: https://www.mathworks.com/help/mpc/ref/mpc.sim.html
These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.