Main Content

frdfun

Apply a function to the frequency response value at each frequency of an frd model object

Since R2020a

Description

fsys = frdfun(fun,sys) applies the function fun to the frequency response value at each frequency of sys and collects the results in fsys.

example

Examples

collapse all

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 =
 
    Frequency(rad/s)          Response      
    ----------------          --------      
           0.0100       -0.1648 + 9.847e-04i
           0.0359       -0.1644 + 3.508e-03i
           0.1292       -0.1597 + 1.130e-02i
           0.4642       -0.1294 + 9.857e-03i
           1.6681       -0.1058 - 7.515e-02i
           5.9948       -0.1883 - 3.050e-01i
          21.5443       -0.7004 - 5.495e-01i
          77.4264       -1.1337 - 2.623e-01i
         278.2559       -1.1946 - 7.725e-02i
        1000.0000       -1.1996 - 2.159e-02i
 
Continuous-time frequency response.

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)
sysImag =
 
    Frequency(rad/s)     Response 
    ----------------     -------- 
           0.0100        9.847e-04
           0.0359        3.508e-03
           0.1292        1.130e-02
           0.4642        9.857e-03
           1.6681       -7.515e-02
           5.9948       -3.050e-01
          21.5443       -5.495e-01
          77.4264       -2.623e-01
         278.2559       -7.725e-02
        1000.0000       -2.159e-02
 
Continuous-time frequency response.

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

sysMag = frdfun(@abs,sys)
sysMag =
 
    Frequency(rad/s)    Response
    ----------------    --------
           0.0100        0.1648 
           0.0359        0.1644 
           0.1292        0.1601 
           0.4642        0.1298 
           1.6681        0.1298 
           5.9948        0.3585 
          21.5443        0.8902 
          77.4264        1.1637 
         278.2559        1.1971 
        1000.0000        1.1998 
 
Continuous-time frequency response.

For this example, consider a 2x2 MIMO frequency response model sys that contains 100 test frequencies for each I/O pair.

Load the frd object sys from the MAT-file frdModelMIMO.mat.

load('frdModelMIMO.mat','sys')
size(sys)
FRD model with 2 outputs, 2 inputs, and 100 frequency points.

Define a function to compute the magnitude of the frequency response of the second I/O pair in sys.

fun = @(h) abs(h(2,2));

Use the frdfun command to apply the function fun to the specific I/O pair in sys.

fsys = frdfun(fun,sys);

Input Arguments

collapse all

Function to be applied to frd model, specified as a MATLAB function. The function fun must accept a single matrix and return a scalar, vector, or matrix of fixed size across frequency.

Frequency response data model, specified as an frd, genfrd, or ufrd model object. When you specify sys as a genfrd or ufrd (Robust Control Toolbox) object, frdfun converts it to an frd object first before applying the function fun.

For more information on frequency response data models, see frd.

Output Arguments

collapse all

Output frequency response data model, returned as an frd model object. frdfun applies the function fun to the frequency response value at each frequency of sys and collects the results in fsys.

For more information on frequency response data models, see frd.

Version History

Introduced in R2020a

See Also

| | (Robust Control Toolbox)