Package: frest

Plot time-domain simulation of nonlinear and linear models


[y,t] = frest.simCompare(simout,sys,input)
[y,t,x] = frest.simCompare(simout,sys,input,x0)


frest.simCompare(simout,sys,input) plots both

  • Simulation output, simout, of the nonlinear Simulink model

    You obtain the output from the frestimate command.

  • Simulation output of the linear model sys for the input signal input

    The linear simulation results are offset by the initial output values in the simout data.

frest.simCompare(simout,sys,input,x0) plots the frequency response simulation output and the simulation output of the linear model with initial state x0. Because you specify the initial state, the linear simulation result is not offset by the initial output values in the simout data.

[y,t] = frest.simCompare(simout,sys,input) returns the linear simulation output response y and the time vector t for the linear model sys with the input signal input. This syntax does not display a plot. The matrix y has as many rows as time samples (length(t)) and as many columns as system outputs.

[y,t,x] = frest.simCompare(simout,sys,input,x0) also returns the state trajectory x for the linear state space model sys with initial state x0.


Compare a time-domain simulation of the Simulink® watertank model and its linear model representation:

% Create input signal for simulation
input = frest.createStep('FinalTime',100);

% Open the Simulink model

% Specify the operating point for the estimation
watertank_spec = operspec('watertank');
op = findop('watertank',watertank_spec)

% Specify portion of model to estimate
io(1)=linio('watertank/PID Controller',1,'input');
io(2)=linio('watertank/Water-Tank System',1,'output');

% Estimate the frequency response of the watertank model
[sysest,simout] = frestimate('watertank',op,io,input)
sys = linearize('watertank',op,io);
The software returns the following plot.

Introduced in R2009b

Was this topic helpful?