# genfrd

Generalized frequency response data (FRD) model

## Description

Use a generalized FRD (`genfrd`

) model to represent a system having
both tunable control design blocks and a fixed numerical component expressed as
frequency-response data. `genfrd`

models keep track of how the tunable
blocks interact with the fixed frequency-response component. For more information about
generalized models with tunable components, see Generalized Models.

## Creation

To construct a `genfrd`

model:

Use model interconnection commands such as

`feedback`

,`series`

,`parallel`

, or`connect`

, or model arithmetic operators such as`+`

or`*`

, to combine a numeric`frd`

model with tunable control design blocks or other models containing control design blocks.For an example, see Interconnect Numeric Frequency-Response Data Model with Tunable Block.

Use the

`frd`

command to sample a`genss`

model at a specified set of frequencies.For an example, see Sample Frequency Response of a Generalized State-Space Model.

Use the

`genfrd`

command to sample any numeric LTI model at specified frequencies.For an example, see Convert Numeric LTI Model to Generalized frd Model.

### Syntax

### Description

`fsys = genfrd(`

converts a static model or dynamic system model to a generalized FRD model and sets the
value of the `sys`

,`frequency`

)`Frequency`

of `fsys`

. If
`sys`

is not an `frd`

model object, `genfrd`

computes the frequency response
at each point in `frequency`

. If `sys`

is an
`frd`

model, `frequency`

must match the values in
`sys.Frequency`

.

`frdsys = genfrd(`

further specifies the units of `sys`

,`frequency`

,`frequencyunit`

)`Frequency`

and sets the
`FrequencyUnit`

property of `fsys`

.

`frdsys = genfrd(`

further specifies the `sys`

,`frequency`

,`frequencyunit`

,`timeunit`

)`TimeUnit`

property of `fsys`

.
This syntax is useful when converting a static model to `genfrd`

form,
because the static model has no associated time unit.

### Input Arguments

`sys`

— Model to convert to `genfrd`

dynamic system model | static model

Model to convert to `genfrd`

, specified as a dynamic system model
or a static model. For instance, `sys`

can be a:

Frequency response data model, such as an

`frd`

model. If`sys`

is an`frd`

model,`frequency`

must match the values in`sys.Frequency`

. To convert an`frd`

model to`genfrd`

form with a different frequency vector, first use`interp`

to resample the`frd`

model.Generalized LTI model, such as a

`genss`

model.Static model, such as a generalized static matrix,

`genmat`

.

The resulting `genfrd`

model has the same control design blocks as
`sys`

. If `sys`

is a numeric LTI model or
other model with no control design blocks, then the resulting `genfrd`

model has zero control design blocks.

## Properties

`Blocks`

— Control Design Blocks

structure

Control Design Blocks included in the generalized LTI model or generalized matrix,
specified as a structure. The field names of `Blocks`

are the
`Name`

property of each control design block.

You can change some attributes of these Control Design Blocks using dot notation. For
example, if the generalized LTI model or generalized matrix `M`

contains a `realp`

tunable parameter `a`

, you can
change the current value of `a`

using:

M.Blocks.a.Value = -1;

`Frequency`

— Frequency values

vector

Frequency values at which system response is sampled, specified as a vector of
values with units given by `FrequencyUnit`

.

`FrequencyUnit`

— Units for frequency vector

`'rad/TimeUnit'`

(default) | `'cycles/TimeUnit'`

| `'rad/s'`

| `'Hz'`

| `'kHz'`

| `'MHz'`

| `'GHz'`

| `'rpm'`

Units of the frequency vector in the `Frequency`

property,
specified as 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 does not resample or convert the data. Modifying the property
changes only the interpretation of the existing data. Use `chgFreqUnit`

to convert the data to different frequency units.

`InputDelay`

— Input delay

`0`

(default) | scalar | `Nu`

-by-1 vector

Input delay for each input channel, specified as one of the following:

Scalar — Specify the input delay for a SISO system or the same delay for all inputs of a multi-input system.

`Nu`

-by-1 vector — Specify separate input delays for input of a multi-input system, where`Nu`

is the number of inputs.

For continuous-time systems, specify input delays in the time unit specified by the `TimeUnit`

property. For discrete-time systems, specify input delays in integer multiples of the sample time, `Ts`

.

For more information, see Time Delays in Linear Systems.

`OutputDelay`

— Output delay

`0`

(default) | scalar | `Ny`

-by-1 vector

Output delay for each output channel, specified as one of the following:

Scalar — Specify the output delay for a SISO system or the same delay for all outputs of a multi-output system.

`Ny`

-by-1 vector — Specify separate output delays for output of a multi-output system, where`Ny`

is the number of outputs.

For continuous-time systems, specify output delays in the time unit specified by the `TimeUnit`

property. For discrete-time systems, specify output delays in integer multiples of the sample time, `Ts`

.

For more information, see Time Delays in Linear Systems.

`InputName`

— Input channel names

`''`

(default) | character vector | cell array of character vectors

Input channel names, specified as one of the following:

A character vector, for single-input models.

A cell array of character vectors, for multi-input models.

`''`

, no names specified, for any input channels.

Alternatively, you can assign input names for multi-input models using automatic vector
expansion. For example, if `sys`

is a two-input model, enter the
following:

`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`

.

Use `InputName`

to:

Identify channels on model display and plots.

Extract subsystems of MIMO systems.

Specify connection points when interconnecting models.

`InputUnit`

— Input channel units

`''`

(default) | character vector | cell array of character vectors

Input channel units, specified as one of the following:

A character vector, for single-input models.

A cell array of character vectors, for multi-input models.

`''`

, no units specified, for any input channels.

Use `InputUnit`

to specify input signal units. `InputUnit`

has no effect on system behavior.

`InputGroup`

— Input channel groups

structure

Input channel groups, specified as a structure. Use `InputGroup`

to assign
the input channels of MIMO systems into groups and refer to each group by name. The
field names of `InputGroup`

are the group names and the field values
are the input channels of each group. For example, enter the following to create input
groups named `controls`

and `noise`

that include input
channels `1`

and `2`

, and `3`

and
`5`

, respectively.

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

You can then extract the subsystem from the `controls`

inputs to all outputs
using the following.

`sys(:,'controls')`

By default, `InputGroup`

is a structure with no fields.

`OutputName`

— Output channel names

`''`

(default) | character vector | cell array of character vectors

Output channel names, specified as one of the following:

A character vector, for single-output models.

A cell array of character vectors, for multi-output models.

`''`

, no names specified, for any output channels.

Alternatively, you can assign output names for multi-output models using automatic vector
expansion. For example, if `sys`

is a two-output model, enter the
following.

`sys.OutputName = 'measurements';`

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

.

You can also use the shorthand notation `y`

to refer to the `OutputName`

property. For example, `sys.y`

is equivalent to `sys.OutputName`

.

Use `OutputName`

to:

Identify channels on model display and plots.

Extract subsystems of MIMO systems.

Specify connection points when interconnecting models.

`OutputUnit`

— Output channel units

`''`

(default) | character vector | cell array of character vectors

Output channel units, specified as one of the following:

A character vector, for single-output models.

A cell array of character vectors, for multi-output models.

`''`

, no units specified, for any output channels.

Use `OutputUnit`

to specify output signal units. `OutputUnit`

has no effect on system behavior.

`OutputGroup`

— Output channel groups

structure

Output channel groups, specified as a structure. Use `OutputGroup`

to assign
the output channels of MIMO systems into groups and refer to each group by name. The
field names of `OutputGroup`

are the group names and the field values
are the output channels of each group. For example, create output groups named
`temperature`

and `measurement`

that include
output channels `1`

, and `3`

and `5`

,
respectively.

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

You can then extract the subsystem from all inputs to the `measurement`

outputs using the following.

`sys('measurement',:)`

By default, `OutputGroup`

is a structure with no fields.

`Notes`

— User-specified text

`{}`

(default) | character vector | cell array of character vectors

User-specified text that you want to associate with the system, specified as a character vector or cell array of character vectors. For example, `'System is MIMO'`

.

`UserData`

— User-specified data

`[]`

(default) | any MATLAB^{®} data type

User-specified data that you want to associate with the system, specified as any MATLAB data type.

`Name`

— System name

`''`

(default) | character vector

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

.

`Ts`

— Sample time

`0`

(default) | positive scalar | `-1`

Sample time, specified as:

`0`

for continuous-time systems.A positive scalar representing the sampling period of a discrete-time system. Specify

`Ts`

in the time unit specified by the`TimeUnit`

property.`-1`

for a discrete-time system with an unspecified sample time.

**Note**

Changing `Ts`

does not discretize or resample the model.

`TimeUnit`

— Time variable units

`'seconds'`

(default) | `'nanoseconds'`

| `'microseconds'`

| `'milliseconds'`

| `'minutes'`

| `'hours'`

| `'days'`

| `'weeks'`

| `'months'`

| `'years'`

| ...

Time variable units, specified as one of the following:

`'nanoseconds'`

`'microseconds'`

`'milliseconds'`

`'seconds'`

`'minutes'`

`'hours'`

`'days'`

`'weeks'`

`'months'`

`'years'`

Changing `TimeUnit`

has no effect on other properties, but changes the overall system behavior. Use `chgTimeUnit`

to convert between time units without modifying system behavior.

`SamplingGrid`

— Sampling grid for model arrays

structure array

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

Use `SamplingGrid`

to track the variable values associated with each model in a model array, including identified linear time-invariant (IDLTI) model arrays.

Set the field names of the 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 must be numeric scalars, and all arrays of sampled values must match the dimensions of the model array.

For example, you can create an 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, you can create a 6-by-9 model array, `M`

, by independently sampling two variables, `zeta`

and `w`

. The following code maps 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 instance, the Simulink
Control Design™ commands `linearize`

(Simulink Control Design) and `slLinearizer`

(Simulink Control Design) populate `SamplingGrid`

automatically.

By default, `SamplingGrid`

is a structure with no fields.

## Object Functions

The following lists contain a representative subset of the functions you can use with
`genfrd`

models. In general, many functions applicable to generalized
state-space (`genss`

) models are also applicable to `genfrd`

models. `genfrd`

models do not work with any time-domain analysis functions.

### Extract Responses

`getIOTransfer` | Closed-loop transfer function from generalized model of control system |

`getLoopTransfer` | Open-loop transfer function of control system represented by
`genss` model |

`getSensitivity` | Sensitivity function from generalized model of control system |

`getCompSensitivity` | Complementary sensitivity function from generalized model of control system |

### Access Blocks and Values

`getValue` | Current value of generalized model |

`getBlockValue` | Get current value of Control Design Block in Generalized Model |

`setBlockValue` | Modify value of Control Design Block in Generalized Model |

### Frequency Response Analysis

`bode` | Bode plot of frequency response, or magnitude and phase data |

`sigma` | Singular value plot of dynamic system |

`nyquist` | Nyquist plot of frequency response |

`nichols` | Nichols chart of frequency response |

`bandwidth` | Frequency response bandwidth |

`freqresp` | Evaluate system response over a grid of frequencies |

`margin` | Gain margin, phase margin, and crossover frequencies |

### Model Interconnection

### Controller Tuning

`systune` | Tune fixed-structure control systems modeled in MATLAB |

## Examples

### Interconnect Numeric Frequency-Response Data Model with Tunable Block

Create a `genfrd`

model by connecting a fixed-value `frd`

model with a tunable control design block.

Load frequency-response data. The file `wtankData.mat`

contains a vector of frequencies, `frequency`

, and the corresponding responses of a system, `response`

. In practice, you might obtain such frequency-response data by simulation, frequency-response estimation, or measurement. Use the data to create a numeric `frd`

model.

```
load wtankData.mat
fsys = frd(response,frequency);
size(fsys)
```

FRD model with 1 outputs, 1 inputs, and 20 frequency points.

Create a tunable PI controller, represented by a `tunablePID`

control design block.

C = tunablePID('C','PI');

Connect the numeric `frd`

model with the tunable PI controller to create a generalized `frd`

model containing one control design block, `C`

.

gsys = feedback(fsys*C,1)

Generalized continuous-time FRD model with 1 outputs, 1 inputs, 20 frequency points, and the following blocks: C: Tunable PID controller, 1 occurrences. Type "frd(gsys)" to see the current value and "gsys.Blocks" to interact with the blocks.

### Sample Frequency Response of a Generalized State-Space Model

Create a generalized state-space model of a second-order system in which the natural frequency and damping coefficients are tunable parameters.

wn = realp('wn',3); zeta = realp('zeta',0.8); sys = tf(1,[(1/wn)^2 2*zeta*(1/wn) 1])

Generalized continuous-time state-space model with 1 outputs, 1 inputs, 2 states, and the following blocks: wn: Scalar parameter, 3 occurrences. zeta: Scalar parameter, 1 occurrences. Type "ss(sys)" to see the current value and "sys.Blocks" to interact with the blocks.

Sample `sys`

at frequencies of interest using the `genfrd`

command. The result is a `genfrd`

model with the same tunable parameters as `sys`

.

frequency = logspace(-1,2,20); fsys = genfrd(sys,frequency)

Generalized continuous-time FRD model with 1 outputs, 1 inputs, 20 frequency points, and the following blocks: wn: Scalar parameter, 3 occurrences. zeta: Scalar parameter, 1 occurrences. Type "frd(fsys)" to see the current value and "fsys.Blocks" to interact with the blocks.

To confirm the correspondence of the `genfrd`

model `fsys`

and the `genss`

model `sys`

, plot the responses of both models with their tunable parameters set to their current values.

bode(sys,"-",fsys,"g*") legend

### Convert Numeric LTI Model to Generalized frd Model

Create a numeric transfer function model and convert it to `genfrd`

form. To do so, use the `genfrd`

command, providing a vector of frequencies at which to sample the response.

sys = tf(1,[1 1]); frequency = logspace(-1,2,20); fsys = genfrd(sys,frequency)

Generalized continuous-time FRD model with 1 outputs, 1 inputs, 20 frequency points, and no blocks. Type "frd(fsys)" to see the current value and "fsys.Blocks" to interact with the blocks.

The resulting model is a `genfrd`

model. However, `fsys`

contains no control design blocks.

fblocks = fsys.Blocks

`fblocks = `*struct with no fields.*

## Version History

**Introduced in R2011a**

## See Also

## MATLAB Command

You clicked a link that corresponds to this MATLAB command:

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

## How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

### Americas

- América Latina (Español)
- Canada (English)
- United States (English)

### Europe

- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)

- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)