%% Bode Plot of Identified Model
% Compare the frequency response of a parametric model, identified from input/output data, to a nonparametric model identified using the same data.
% Identify parametric and nonparametric models based on data.

load iddata2 z2;
w = linspace(0,10*pi,128);
sys_np = spa(z2,[],w);
sys_p = tfest(z2,2);

% Using the spa and tfest commands requires System Identification Toolbox™ software.
% sys_np is a nonparametric identified model. sys_p is a parametric identified model.
%
% Create a Bode plot that includes both systems.

bode(sys_np,sys_p,w);
legend('sys-np','sys-p')

% You can display the confidence region on the Bode plot by right-clicking the plot and selecting Characteristics > Confidence Region.
% Copyright 2012 The MathWorks, Inc.