|On this page…|
This example shows how to validate linearization results by comparing the simulated output of the nonlinear model and the linearized model.
Linearize Simulink® model.
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); 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.
Create input signal for validation. For example, a step input signal:
input = frest.createStep('Ts',0.1,... 'StepTime',1,... 'StepSize',1e-5,... 'FinalTime',500);
Simulate the Simulink model using the input signal.
[~,simout] = frestimate(sys,op,sys_io,input);
simout is the simulated output of the nonlinear model.
Simulate the linear model sys, and compare the time-domain responses of the linear and nonlinear Simulink model.
The step response of the nonlinear model and linearized model are close, which validates that the linearization is accurate.
Increase the amplitude of the step signal from 1.0e-005 to 1.
input = frest.createStep('Ts',0.1,... 'StepTime',1,... 'StepSize',1,... 'FinalTime',500);
Repeat the frequency response estimation with the increased amplitude of the input signal, and compare this time response plot to the exact linearization results.
[~,simout2] = frestimate(sys,op,sys_io,input); frest.simCompare(simout2,linsys,input) legend('FRESTIMATE results with Custom input',... 'Linear simulation of linsys with Custom input',... 'Location','SouthEast')
The step response of linear system you obtained using exact linearization does not match the step response of the estimated frequency response with large input signal amplitude.
This result indicates that linear model obtained using exact linearization does not behave linearly you begin to deviate from the specified operating point.
For time-domain validation of linearization, use frest.createStep to create a step signal. Use the step signal as an input to frest.simCompare, which compares the simulated output of the nonlinear model and the linearized model.
The step input helps you assess whether the linear model accurately captures the dominant time constants as it goes through the step transients.
The step input also shows whether you correctly captured the DC gain of the Simulink model by comparing the final value of the exact linearization simulation with the frequency response estimation.