Accelerating the pace of engineering and science

# evalSpec

Evaluate tuning requirements for tuned control system

## Syntax

• [Hspec,fval] = evalSpec(Req,T) example
• [Hspec,fval] = evalSpec(Req,T,Info) example

## Description

example

[Hspec,fval] = evalSpec(Req,T) returns the normalized value, fval, of a tuning requirement evaluated for a tuned control system T. The evalSpec command also returns the transfer function, Hspec, used to compute this value.

example

[Hspec,fval] = evalSpec(Req,T,Info) uses the Info structure returned by systune for correct scaling of MIMO open-loop requirements, such as loop shapes and stability margins.

## Examples

expand all

### Evaluate Requirements for Tuned System

Tune a control system with systune , and evaluate the tuning requirements with evalSpec.

```open_system('rct_airframe2')
```

Create tracking, roll-off, stability margin, and disturbance rejection requirements for tuning the control system.

```Req1 = TuningGoal.Tracking('az ref','az',1);
Req2 = TuningGoal.Gain('delta fin','delta fin',tf(25,[1 0]));
Req3 = TuningGoal.Margins('delta fin',7,45);
MaxGain = frd([2 200 200],[0.02 2 200]);
Req4 = TuningGoal.Gain('delta fin','az',MaxGain);
```

Create a slTunable interface and tune the model using these tuning requirements.

```ST0 = slTunable('rct_airframe2','MIMO Controller');

rng default
[ST1,fSoft,~,Info] = systune(ST0,[Req1,Req2,Req3,Req4]);
```
```Final: Soft = 1.15, Hard = -Inf, Iterations = 57
```

ST1 is a tuned version of the slTunable interface to the control system. ST1 contains the tuned values of the tunable parameters of the MIMO controller in the model.

Evaluate the margin requirement for the tuned system.

```[hspec,fval] = evalSpec(Req3,ST1,Info);
fval
```
```fval =

0.5477

```

The normalized value of the requirement is less than 1, indicating that the tuned system satisfies the margin requirement. For more information about how the normalized value of this requirement is calculated, see the TuningGoal.Margins reference page.

Evaluate the tracking requirement for the tuned system.

```[hspec,fval] = evalSpec(Req1,ST1,Info);
fval
```
```fval =

1.1498

```

The tracking requirement is nearly met, but the value exceeds 1, indicating a small violation. To further assess the violation, you can use viewSpec to examine the requirement against the tuned control system as a function of frequency.

## Input Arguments

expand all

### Req — Tuning requirement to evaluateTuningGoal requirement object | vector of TuningGoal objects

Tuning requirement to evaluate, specified as a TuningGoal requirement object or vector of TuningGoal objects. TuningGoal requirement objects include:

• TuningGoal.Tracking

• TuningGoal.Gain

• TuningGoal.WeightedGain

• TuningGoal.Variance

• TuningGoal.WeightedVariance

• TuningGoal.LoopShape

• TuningGoal.Margins

• TuningGoal.Poles

• TuningGoal.ControllerPoles

### T — Tuned control systemgeneralized state-space model | slTuner interface object

Tuned control system, specified as a generalized state-space (genss) model or an slTuner interface to a Simulink® model. T is typically the result of using the tuning requirement to tune control system parameters with systune.

Example: [T,fSoft,gHard,Info] = systune(T0,SoftReq,HardReq), where T0 is a tunable genss model

Example: [T,fSoft,gHard,Info] = systune(ST0,SoftReq,HardReq), where ST0 is a slTuner interface object

### Info — System informationdata structure returned by systune

System information, specified as the data structure returned by systune when you use that command to tune a control system. Use Info when validating tuned MIMO systems. Doing so ensures that viewSpec correctly scales open-loop requirements such as loop shapes and stability margins.

## Output Arguments

expand all

### Hspec — transfer function associated with requirementstate-space model

Transfer function associated with the tuning requirement, returned as a state-space (ss) model. evalSpec uses Hspec to compute the evaluated requirement, fval.

For example, suppose Req is a TuningGoal gain requirement that limits the gain, H(s), between some specified input and output to the gain profile, w(s). In that case, Hspec is given by:

$Hspec\left(s\right)=\frac{1}{w\left(s\right)}H\left(s\right).$

fval is the peak gain of Hspec. If H(s) satisfies the tuning requirement, fval <= 1.

### fval — Normalized value of tuning requirementpositive scalar

Normalized value of tuning requirement, returned as a positive scalar. The normalized value is a measure of how closely the requirement is met in the tuned system. The tuning requirement is satisfied if fval < 1. For information about how each type of TuningGoal requirement is converted into a normalized value, see the TuningGoal requirement objects.