Documentation Center

  • Trial Software
  • Product Updates

loopswitch

Switch for opening and closing feedback loops

Syntax

S = loopswitch(name)
S = loopswitch(name,N)

Description

Control Design Block for creating loop-opening locations in a model of a control system. You can combine a loopswitch block with numeric LTI models, tunable LTI models, and other Control Design Blocks to build tunable models of control systems. A loopswitch block in your control system marks a location where you can optionally open a feedback loop. You can use an optional loop opening to compute open-loop quantities such as point-to-point transfer functions (see getLoopTransfer) or stability margins. You can also use a loopswitch block to mark an input or output location for computing closed-loop transfer functions with getIOTransfer.

loopswitch blocks are also useful when tuning a control system using Robust Control Toolbox™ tuning commands such as systune. You can use a loopswitch block to mark a loop-opening location for open-loop tuning requirements such as TuningGoal.LoopShape or TuningGoal.Margins. You can also use a loopswitch block to mark the specified input or output for tuning requirements such as TuningGoal.Gain.

Construction

S = loopswitch(name) creates a switch block for opening or closing a SISO feedback loop.

S = loopswitch(name,N) creates a switch for a MIMO feedback loop with N channels.

Input Arguments

name

Switch block name, specified as a string. This input argument sets the value of the Name property of the switch block. (See Properties.)

N

Number of channels for a multichannel switch, specified as a scalar integer.

Properties

Location

Names of feedback channels in the switch block, specified as a string or a cell array of strings.

By default, the feedback loops are named after the block. For example, if you have a SISO switch block, X that has name 'X', then X.Location = 'X' by default. If you have a a multi-channel switch block, then X.Location = {'X(1)','X(2)',...} by default. Set X.Location to a different value if you want to customize the channel names.

Open

Switch state, specified as a logical value or vector of logical values. For example, if you have a SISO switch block, X, then the value X.Open = 1 opens the switch. if you have a multi-channel switch block, then X.Open is a logical vector with as many entries as X has channels.

Default: 0 for all channels

Ts

Sampling 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 sampling time, set Ts = -1.

Changing this property does not discretize or resample the model. Use c2d and d2c to convert between continuous- and discrete-time representations. Use d2d to change the sampling time of a discrete-time system.

Default: 0 (continuous time)

TimeUnit

String representing the unit of the time variable. For continuous-time models, this property represents any time delays in the model. For discrete-time models, it represents the sampling time Ts. Use any of the following values:

  • 'nanoseconds'

  • 'microseconds'

  • 'milliseconds'

  • 'seconds'

  • 'minutes'

  • 'hours'

  • 'days'

  • 'weeks'

  • 'months'

  • 'years'

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

Default: 'seconds'

InputName

Input channel names. Set InputName to a string for single-input model. For a multi-input model, set InputName to a cell array of strings.

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: Empty string '' for all input channels

InputUnit

Input channel units. Use InputUnit to keep track of input signal units. For a single-input model, set InputUnit to a string. For a multi-input model, set InputUnit to a cell array of strings. InputUnit has no effect on system behavior.

Default: Empty string '' 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. Set OutputName to a string for single-output model. For a multi-output model, set OutputName to a cell array of strings.

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 to 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: Empty string '' for all input channels

OutputUnit

Output channel units. Use OutputUnit to keep track of output signal units. For a single-output model, set OutputUnit to a string. For a multi-output model, set OutputUnit to a cell array of strings. OutputUnit has no effect on system behavior.

Default: Empty string '' for all input 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. Set Name to a string to label the system.

Default: ''

Notes

Any text that you want to associate with the system. Set Notes to a string or a cell array of strings.

Default: {}

UserData

Any type of data you wish to associate with system. Set UserData to any MATLAB® data type.

Default: []

Examples

expand all

Feedback Loop with Loop-Opening Switch

Create a model of the following feedback loop with a loop-opening switch in the feedback path.

G = 1/(s+2) is the plant model, C is a tunable PI controller, and X is a loop-opening switch.

G = tf(1,[1 2]);
C = ltiblock.pid('C','pi');
X = loopswitch('X');
T = feedback(G*C,X);

T is a tunable genss model. T.Blocks contains the Control Design Blocks of the model, C, and the switch, X. By default, X is closed.

Examine the step response of T.

stepplot(T)

With X closed, the response of T is stable.

Open the switch to obtain the open-loop response from r to y.

T.Blocks.X.Open = true;
stepplot(T)

Close the switch to continue working with the closed-loop model.

T.Blocks.X.Open = false;

More About

expand all

Tips

  • By default, the switch S is closed. Set S.Open = true to create a switch location that is open by default. For a multichannel switch, you can set S.Open to a logical vector with N entries. Doing so opens only a subset of the feedback loops.

See Also

|

Was this topic helpful?