%% Singular Value Plot of Identified Parametric and Nonparametric Models
% For this example, compare the SV for the frequencies of a parametric model, identified from input/output data, to a non-parametric model identified using the same data. Identify parametric and non-parametric models based on the data.
% Load the data and create the parametric and non-parametric models using tfest and spa, respectively.

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

% spa and tfest require System Identification Toolbox™ software. The model sys_np is a non-parametric identified model while, sys_p is a parametric identified model.
% Create an options set to turn the grid on. Then, create a sigma plot that includes both systems using this options set.

plotoptions = sigmaoptions;  
plotoptions.Grid = 'on';
h = sigmaplot(sys_p,'b--',sys_np,'r--',w,plotoptions);
legend('Parametric Model','Non-Parametric model');

% Copyright 2021 The MathWorks, Inc.