Validate Linearization In Time Domain
Validate Linearization in Time Domain
This example shows how to validate linearization results by comparing the simulated
output of the nonlinear model and the linearized model.
(^1) Linearize Simulink model.
For example:
sys = 'watertank';
load_system(sys);
sys_io(1) = linio('watertank/PID Controller',1,'input');
sys_io(2) = linio('watertank/Water-Tank System',1,'openoutput');
opspec = operspec(sys);
op = findop(sys,opspec,findopOptions('DisplayReport','off'));
linsys = linearize(sys,op,sys_io);
If you linearized your model in the Linear Analysis Tool, you must export the linear
model to the MATLAB workspace.
(^2) Create input signal for validation. For example, a step input signal:
input = frest.createStep('Ts',0.1,...
'StepTime',1,...
'StepSize',1e-5,...
'FinalTime',500);
(^3) Simulate the Simulink model using the input signal.
[~,simout] = frestimate(sys,op,sys_io,input);
simout is the simulated output of the nonlinear model.
(^4) Simulate the linear model sys, and compare the time-domain responses of the linear
and nonlinear Simulink model.
frest.simCompare(simout,linsys,input)
legend('FRESTIMATE results with Custom input',...
'Linear simulation of linsys with Custom input',...
'Location','SouthEast');