frd

Create frequency-response data model, convert to frequency-response data model

Syntax

sys = frd(response,frequency)
sys = frd(response,frequency,Ts)
sys = frd
sysfrd = frd(sys,frequency)
sysfrd = frd(sys,frequency,units)

Description

sys = frd(response,frequency) creates a frequency-response data (frd) model object sys from the frequency response data stored in the multidimensional array response. The vector frequency represents the underlying frequencies for the frequency response data. See Data Format for the Argument Response in FRD Models for a list of response data formats.

sys = frd(response,frequency,Ts) creates a discrete-time frd model object sys with scalar sample time Ts. Set Ts = -1 to create a discrete-time frd model object without specifying the sample time.

sys = frd creates an empty frd model object.

The input argument list for any of these syntaxes can be followed by property name/property value pairs of the form

'PropertyName',PropertyValue

You can use these extra arguments to set the various properties the model. For more information about available properties of frd models, see Properties.

To force an FRD model sys to inherit all of its generic LTI properties from any existing LTI model refsys, use the syntax

sys = frd(response,frequency,ltisys)

sysfrd = frd(sys,frequency) converts a dynamic system model sys to frequency response data form. The frequency response is computed at the frequencies provided by the vector frequency, in rad/TimeUnit, where TimeUnit is the time units of the input dynamic system, specified in the TimeUnit property of sys.

sysfrd = frd(sys,frequency,units) converts a dynamic system model to an frd model and interprets frequencies in the frequency vector to have the units specified by units. For a list of values that units can take, see the FrequencyUnit property in Properties.

Arguments

When you specify a SISO or MIMO FRD model, or an array of FRD models, the input argument frequency is always a vector of length Nf, where Nf is the number of frequency data points in the FRD. The specification of the input argument response is summarized in the following table.

Data Format for the Argument Response in FRD Models

Model Form

Response Data Format

SISO model

Vector of length Nf for which response(i) is the frequency response at the frequency frequency(i)

MIMO model with Ny outputs and Nu inputs

Ny-by-Nu-by-Nf multidimensional array for which response(i,j,k) specifies the frequency response from input j to output i at frequency frequency(k)

S1-by-...-by-Sn array of models with Ny outputs and Nu inputs

Multidimensional array of size [Ny Nu S1 ... Sn] for which response(i,j,k,:) specifies the array of frequency response data from input j to output i at frequency frequency(k)

Properties

frd objects have the following properties:

Frequency

Frequency points of the frequency response data. Specify Frequency values in the units specified by the FrequencyUnit property.

FrequencyUnit

Frequency units of the model.

FrequencyUnit specifies the units of the frequency vector in the Frequency property. Set FrequencyUnit to one of the following values:

  • 'rad/TimeUnit'

  • 'cycles/TimeUnit'

  • 'rad/s'

  • 'Hz'

  • 'kHz'

  • 'MHz'

  • 'GHz'

  • 'rpm'

The units 'rad/TimeUnit' and 'cycles/TimeUnit' are relative to the time units specified in the TimeUnit property.

Changing this property changes the overall system behavior. Use chgFreqUnit to convert between frequency units without modifying system behavior.

Default: 'rad/TimeUnit'

ResponseData

Frequency response data.

The 'ResponseData' property stores the frequency response data as a 3-D array of complex numbers. For SISO systems, 'ResponseData' is a vector of frequency response values at the frequency points specified in the 'Frequency' property. For MIMO systems with Nu inputs and Ny outputs, 'ResponseData' is an array of size [Ny Nu Nw], where Nw is the number of frequency points.

IODelay

Transport delays. IODelay is a numeric array specifying a separate transport delay for each input/output pair.

For continuous-time systems, specify transport delays in the time unit stored in the TimeUnit property. For discrete-time systems, specify transport delays in integer multiples of the sample time, Ts.

For a MIMO system with Ny outputs and Nu inputs, set IODelay to a Ny-by-Nu array. Each entry of this array is a numerical value that represents the transport delay for the corresponding input/output pair. You can also set IODelay to a scalar value to apply the same delay to all input/output pairs.

Default: 0 for all input/output pairs

InputDelay

Input delay for each input channel, specified as a scalar value or numeric vector. For continuous-time systems, specify input delays in the time unit stored in the TimeUnit property. For discrete-time systems, specify input delays in integer multiples of the sample time Ts. For example, InputDelay = 3 means a delay of three sample times.

For a system with Nu inputs, set InputDelay to an Nu-by-1 vector. Each entry of this vector is a numerical value that represents the input delay for the corresponding input channel.

You can also set InputDelay to a scalar value to apply the same delay to all channels.

Default: 0

OutputDelay

Output delays. OutputDelay is a numeric vector specifying a time delay for each output channel. For continuous-time systems, specify output delays in the time unit stored in the TimeUnit property. For discrete-time systems, specify output delays in integer multiples of the sample time Ts. For example, OutputDelay = 3 means a delay of three sampling periods.

For a system with Ny outputs, set OutputDelay to an Ny-by-1 vector, where each entry is a numerical value representing the output delay for the corresponding output channel. You can also set OutputDelay to a scalar value to apply the same delay to all channels.

Default: 0 for all output channels

Ts

Sample time. For continuous-time models, Ts = 0. For discrete-time models, Ts is a positive scalar representing the sampling period. This value is expressed in the unit specified by the TimeUnit property of the model. To denote a discrete-time model with unspecified sample time, set Ts = -1.

Changing this property does not discretize or resample the model.

Default: 0 (continuous time)

TimeUnit

Units for the time variable, the sample time Ts, and any time delays in the model, specified as one of the following values:

  • 'nanoseconds'

  • 'microseconds'

  • 'milliseconds'

  • 'seconds'

  • 'minutes'

  • 'hours'

  • 'days'

  • 'weeks'

  • 'months'

  • 'years'

Changing this property has no effect on other properties, and therefore changes the overall system behavior. Use chgTimeUnit to convert between time units without modifying system behavior.

Default: 'seconds'

InputName

Input channel names, specified as one of the following:

  • Character vector — For single-input models, for example, 'controls'.

  • Cell array of character vectors — For multi-input models.

Alternatively, use automatic vector expansion to assign input names for multi-input models. For example, if sys is a two-input model, enter:

sys.InputName = 'controls';

The input names automatically expand to {'controls(1)';'controls(2)'}.

You can use the shorthand notation u to refer to the InputName property. For example, sys.u is equivalent to sys.InputName.

Input channel names have several uses, including:

  • Identifying channels on model display and plots

  • Extracting subsystems of MIMO systems

  • Specifying connection points when interconnecting models

Default: '' for all input channels

InputUnit

Input channel units, specified as one of the following:

  • Character vector — For single-input models, for example, 'seconds'.

  • Cell array of character vectors — For multi-input models.

Use InputUnit to keep track of input signal units. InputUnit has no effect on system behavior.

Default: '' for all input channels

InputGroup

Input channel groups. The InputGroup property lets you assign the input channels of MIMO systems into groups and refer to each group by name. Specify input groups as a structure. In this structure, field names are the group names, and field values are the input channels belonging to each group. For example:

sys.InputGroup.controls = [1 2];
sys.InputGroup.noise = [3 5];

creates input groups named controls and noise that include input channels 1, 2 and 3, 5, respectively. You can then extract the subsystem from the controls inputs to all outputs using:

sys(:,'controls')

Default: Struct with no fields

OutputName

Output channel names, specified as one of the following:

  • Character vector — For single-output models. For example, 'measurements'.

  • Cell array of character vectors — For multi-output models.

Alternatively, use automatic vector expansion to assign output names for multi-output models. For example, if sys is a two-output model, enter:

sys.OutputName = 'measurements';

The output names automatically expand to {'measurements(1)';'measurements(2)'}.

You can use the shorthand notation y to refer to the OutputName property. For example, sys.y is equivalent to sys.OutputName.

Output channel names have several uses, including:

  • Identifying channels on model display and plots

  • Extracting subsystems of MIMO systems

  • Specifying connection points when interconnecting models

Default: '' for all output channels

OutputUnit

Output channel units, specified as one of the following:

  • Character vector — For single-output models. For example, 'seconds'.

  • Cell array of character vectors — For multi-output models.

Use OutputUnit to keep track of output signal units. OutputUnit has no effect on system behavior.

Default: '' for all output channels

OutputGroup

Output channel groups. The OutputGroup property lets you assign the output channels of MIMO systems into groups and refer to each group by name. Specify output groups as a structure. In this structure, field names are the group names, and field values are the output channels belonging to each group. For example:

sys.OutputGroup.temperature = [1];
sys.InputGroup.measurement = [3 5];

creates output groups named temperature and measurement that include output channels 1, and 3, 5, respectively. You can then extract the subsystem from all inputs to the measurement outputs using:

sys('measurement',:)

Default: Struct with no fields

Name

System name, specified as a character vector. For example, 'system_1'.

Default: ''

Notes

Any text that you want to associate with the system, stored as a string or a cell array of character vectors. The property stores whichever data type you provide. For instance, if sys1 and sys2 are dynamic system models, you can set their Notes properties as follows:

sys1.Notes = "sys1 has a string.";
sys2.Notes = 'sys2 has a character vector.';
sys1.Notes
sys2.Notes
ans = 

    "sys1 has a string."


ans =

    'sys2 has a character vector.'

Default: [0×1 string]

UserData

Any type of data you want to associate with system, specified as any MATLAB® data type.

Default: []

SamplingGrid

Sampling grid for model arrays, specified as a data structure.

For model arrays that are derived by sampling one or more independent variables, this property tracks the variable values associated with each model in the array. This information appears when you display or plot the model array. Use this information to trace results back to the independent variables.

Set the field names of the data structure to the names of the sampling variables. Set the field values to the sampled variable values associated with each model in the array. All sampling variables should be numeric and scalar valued, and all arrays of sampled values should match the dimensions of the model array.

For example, suppose you create a 11-by-1 array of linear models, sysarr, by taking snapshots of a linear time-varying system at times t = 0:10. The following code stores the time samples with the linear models.

 sysarr.SamplingGrid = struct('time',0:10)

Similarly, suppose you create a 6-by-9 model array, M, by independently sampling two variables, zeta and w. The following code attaches the (zeta,w) values to M.

[zeta,w] = ndgrid(<6 values of zeta>,<9 values of w>)
M.SamplingGrid = struct('zeta',zeta,'w',w)

When you display M, each entry in the array includes the corresponding zeta and w values.

M
M(:,:,1,1) [zeta=0.3, w=5] =
 
        25
  --------------
  s^2 + 3 s + 25
 

M(:,:,2,1) [zeta=0.35, w=5] =
 
         25
  ----------------
  s^2 + 3.5 s + 25
 
...

For model arrays generated by linearizing a Simulink® model at multiple parameter values or operating points, the software populates SamplingGrid automatically with the variable values that correspond to each entry in the array. For example, the Simulink Control Design™ commands linearize (Simulink Control Design) and slLinearizer (Simulink Control Design) populate SamplingGrid in this way.

Default: []

Examples

Create Frequency-Response Model

Create a SISO FRD model from a frequency vector and response data:

% generate a frequency vector and response data 
freq = logspace(1,2);
resp = .05*(freq).*exp(i*2*freq);
% Create a FRD model
sys = frd(resp,freq);
Introduced before R2006a