%% Convert State-Space Model to Frequency-Response Data Model
% For this example, compute the frd model of the following state-space model:
% A=\left\lbrack \begin{array}{cc}
% -2 & -1\\
% 1 & -2
% \end{array}\right\rbrack ,\;B=\left\lbrack \begin{array}{cc}
% 1 & 1\\
% 2 & -1
% \end{array}\right\rbrack ,\;C=\left\lbrack \begin{array}{cc}
% 1 & 0
% \end{array}\right\rbrack ,\;D=\left\lbrack \begin{array}{cc}
% 0 & 1
% \end{array}\right\rbrack \;
% Create a state-space model using the state-space matrices.

A = [-2 -1;1 -2];
B = [1 1;2 -1];
C = [1 0];
D = [0 1];
ltiSys = ss(A,B,C,D);

% Convert the state-space model ltiSys to a frd model for frequencies between 0.01 and 100 rad/s.

w = logspace(-2,2,50);
sys = frd(ltiSys,w);

% Compare the frequency responses.

bode(ltiSys,'b',sys,'r--')

% The responses are identical.
% Copyright 2021 The MathWorks, Inc.