%% Apply Functions to Frequency Response Model
% For this example, create a frequency response data model by computing the response of a transfer function on a grid of frequencies. For this example, assume a set of 10 frequencies.

H = tf([-1.2,-2.4,-1.5],[1,20,9.1]);
w = logspace(-2,3,10);
sys = frd(H,w)

% sys is a SISO frequency response data (frd) model containing the frequency response at 10 frequencies.
% Use the frdfun command to apply the function imag on the frd model sys to obtain the imaginary parts of the frequency response as a function of frequency.

sysImag = frdfun(@imag,sys)

% You can also obtain the magnitude of the frequency response of sys with the abs function.

sysMag = frdfun(@abs,sys)

% Copyright 2019 The MathWorks, Inc.