# addResponse

## Description

`addResponse(`

adds
the response for dynamic system model
`rp`

,`sys`

)`sys`

to the existing response plot associated with chart object
`rp`

.

The time and frequency specifications for the added response are computed automatically.

The line width and color for the response are assigned automatically.

`addResponse(___,Name=Value)`

configures added responses
using one or more name-value arguments.

## Examples

### Plot Multiple Step Responses

Create a second-order transfer function with a damping ratio of 0.5.

wn = 2; zeta = 0.5; sys = tf(wn^2,[1,2*zeta*wn,wn^2]);

Plot the step response of this system.

sp = stepplot(sys);

Create a transfer function with a lower damping ratio and add it to the step plot.

zetaL = 0.25; sysL = tf(wn^2,[1,2*zetaL*wn,wn^2]); addResponse(sp,sysL);

Create a transfer function with a higher damping ratio and add it to the step plot.

zetaH = 0.75; sysH = tf(wn^2,[1,2*zetaH*wn,wn^2]); addResponse(sp,sysH);

Add a legend to the plot.

legend("zeta = 0.5","zeta = 0.25","zeta = 0.75",... Location="southeast");

## Input Arguments

`rp`

— Response plot chart object

`impulseplot`

object | `initialplot`

object | `stepplot`

object | `lsimplot`

object | `bodeplot`

object | `nicholsplot`

object | `nyquistplot`

object | `sigmaplot`

object | `pzplot`

object | `iopzplot`

object | `rlocusplot`

object

Response plot chart object, specified as one of the following objects:

`impulseplot`

— Impulse response`initialplot`

— Initial condition response`stepplot`

— Step response`lsimplot`

— Simulated time response to arbitrary input`bodeplot`

— Bode frequency response`nicholsplot`

— Nichols frequency response`nyquistplot`

— Nyquist response`sigmaplot`

— Singular values for frequency response`pzplot`

— Pole-zero map`iopzplot`

— Plot pole-zero map for input-output pairs`rlocusplot`

— Root locus plot

`sys`

— Dynamic system

dynamic system model | model array

Dynamic system, specified as a SISO or MIMO dynamic system model or array of dynamic system models. Dynamic systems that you can use include:

Continuous-time or discrete-time numeric LTI models, such as

`tf`

,`zpk`

, or`ss`

models.Generalized or uncertain LTI models such as

`genss`

or`uss`

(Robust Control Toolbox) models. Using uncertain models requires Robust Control Toolbox™ software.For tunable control design blocks, the function evaluates the model at its current value to plot the response.

For uncertain control design blocks, the function plots the nominal value and random samples of the model.

Frequency-response data models such as

`frd`

models. For such models, the function plots the response at the frequencies defined in the model.Identified LTI models, such as

`idtf`

(System Identification Toolbox),`idss`

(System Identification Toolbox), or`idproc`

(System Identification Toolbox) models. Using identified models requires System Identification Toolbox™ software.Linear time-varying (

`ltvss`

) and linear parameter-varying (`lpvss`

) models.

#### Dependencies

The supported models depend on the type of chart object specified in
`rp`

.

Frequency-response data models are supported only for

`bodeplot`

,`nicholsplot`

,`nyquistplot`

, and`sigmaplot`

chart objects.Linear time-varying and linear parameter-varying models are supported only for

`stepplot`

,`impulseplot`

,`initialplot`

, and`lsimplot`

chart objects.For

`rlocusplot`

chart objects, only SISO models are supported.

### Name-Value Arguments

Specify optional pairs of arguments as
`Name1=Value1,...,NameN=ValueN`

, where `Name`

is
the argument name and `Value`

is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.

**Example: **`Color="red"`

sets the plot color to red.

**Plot Appearance**

`Color`

— Plot color

RGB triplet | hexadecimal color code | color name

Plot color, specified as an RGB triplet or a hexadecimal color code and stored as an RGB triplet.

Alternatively, you can specify some common colors by name. The following table lists these colors and their corresponding RGB triplets and hexadecimal color codes.

Color Name | RGB Triplet | Hexadecimal Color Code |
---|---|---|

| `[1 0 0]` | `#FF0000` |

| `[0 1 0]` | `#00FF00` |

| `[0 0 1]` | `#0000FF` |

| `[0 1 1]` | `#00FFFF` |

| `[1 0 1]` | `#FF00FF` |

| `[1 1 0]` | `#FFFF00` |

| `[0 0 0]` | `#000000` |

| `[1 1 1]` | `#FFFFFF` |

`LineStyle`

— Line style

`"-"`

| `"--"`

| `":"`

| `"-."`

Line style, specified as one of the following values.

Line Style | Description |
---|---|

`"-"` | Solid line |

`"--"` | Dashed line |

`":"` | Dotted line |

`"-."` | Dash-dotted line |

`MarkerStyle`

— Marker style

`"none"`

| `"o"`

| `"+"`

| `"*"`

| `"."`

| ...

Marker style, specified as one of the following values.

Marker | Description |
---|---|

`"none"` | No marker |

`"o"` | Circle |

`"+"` | Plus sign |

`"*"` | Asterisk |

`"."` | Point |

`"x"` | Cross |

`"_"` | Horizontal line |

`"|"` | Vertical line |

`"s"` | Square |

`"d"` | Diamond |

`"^"` | Upward-pointing triangle |

`"v"` | Downward-pointing triangle |

`">"` | Right-pointing triangle |

`"<"` | Left-pointing triangle |

`"p"` | Pentagram |

`"h"` | Hexagram |

`Options`

— Plot options

`timeoptions`

object | `bodeoptions`

object | object | `nicholsoptions`

object | `nyquistoptions`

object | `sigmaoptions`

object | `pzoptions`

object

Plot options, specified as one of the following objects, depending on the type of
chart object specified in `rp`

.

Options Object | Chart Object `rp` |
---|---|

`timeoptions` | `impulseplot` , `initialplot` ,
`stepplot` , and `lsimplot` |

`bodeoptions` | `bodeplot` |

`nicholsoptions` | `nicholsplot` |

`nyquistoptions` | `nyquistplot` |

`sigmaoptions` | `sigmapplot` |

`pzoptions` | `pzplot` , `iopzplot` , and
`rlocusplot` |

**Step and Impulse Response**

`Time`

— Time steps

positive scalar | two-element vector | vector | `[]`

Time steps at which to compute the response, specified as one of the following:

Positive scalar

`tFinal`

— Compute the response from`t = 0`

to`t = tFinal`

.Two-element vector

`[t0 tFinal]`

— Compute the response from`t = t0`

to`t = tFinal`

.*(since R2023b)*Vector

`Ti:dt:Tf`

— Compute the response for the time points specified in`t`

.For continuous-time systems,

`dt`

is the sample time of a discrete approximation to the continuous system.For discrete-time systems with a specified sample time,

`dt`

must match the sample time property`Ts`

of`sys`

.For discrete-time systems with an unspecified sample time (

`Ts = -1`

),`dt`

must be`1`

.

`[]`

— Automatically select time values based on system dynamics.

When you specify a time range using either `tFinal`

or
`[t0 tFinal]`

:

For continuous-time systems, the function automatically determines the size of the time step and number of points based on the system dynamics.

For discrete-time systems with a specified sample time, the function uses the sample time of

`sys`

as the step size.For discrete-time systems with unspecified sample time (

`Ts = -1`

), the function interprets`tFinal`

as the number of sampling periods to simulate with a sample time of 1 second.

Express `t`

using the time units specified in the
`TimeUnit`

property of `sys`

.

If you specified a step delay `td`

using
`Config`

, the function applies the step at ```
t =
t0+td
```

.

#### Dependencies

This argument is supported only when `rp`

is a
`stepplot`

object or an `impulse`

object.

`Parameter`

— LPV model parameter trajectory

matrix | function handle

Parameter trajectory of the LPV model, specified as a matrix or a function handle.

For exogenous or explicit trajectories, specify

`p`

as a matrix with dimensions*N*-by-*Np*, where*N*is the number of time samples and*Np*is the number of parameters.Thus, the row vector

`p(i,:)`

contains the parameter values at the*i*th time step.For endogenous or implicit trajectories, specify

`p`

as a function handle of the form*p*=*F*(*t*,*x*,*u*) in continuous time and*p*=*F*(*k*,*x*,*u*) in discrete time that gives parameters as a function of time*t*or time sample*k*, state*x*, and input*u*.This option is useful when you want to simulate quasi-LPV models. For an example, see Step Response of LPV Model.

#### Dependencies

This argument is supported only when `sys`

is an LPV model
and `rp`

is a `stepplot`

object or an
`impulse`

object.

`Config`

— Response configuration

`RespConfig`

object

Configuration of the applied signal, specified as a `RespConfig`

object. By default, `step`

applies
an input that goes from 0 to 1 at time `t = 0`

. Use this input
argument to change the configuration of the step input. See Response to Custom Step Input for an example.

For `lpvss`

and
`ltvss`

models with offsets
(*x*_{0}(*t*),*u*_{0}(*t*)),
you can use `RespConfig`

to define the input relative to
*u*_{0}(*t*,*p*)
and initialize the simulation with the state
*x*_{0}(*t*,*p*).

This argument is supported only when `rp`

is a
`stepplot`

object or an `impulse`

object.

#### Dependencies

This argument is supported only when `rp`

is a
`stepplot`

object or an `impulse`

object.

**Frequency Response**

`Frequency`

— Frequencies

`{wmin,wmax}`

| vector | `[]`

Frequencies at which to compute the response, specified as one of the following:

Cell array of the form

`{wmin,wmax}`

— Compute the response at frequencies in the range from`wmin`

to`wmax`

. If`wmax`

is greater than the Nyquist frequency of`sys`

, the response is computed only up to the Nyquist frequency.Vector of frequencies — Compute the response at each specified frequency. For example, use

`logspace`

to generate a row vector with logarithmically spaced frequency values. The vector`w`

can contain both positive and negative frequencies.`[]`

— Automatically select frequencies based on system dynamics.

For models with complex coefficients, if you specify a frequency range of
[*w*_{min},*w*_{max}]
for your plot, then in:

Log frequency scale, the plot frequency limits are set to [

*w*_{min},*w*_{max}] and the plot shows two branches, one for positive frequencies [*w*_{min},*w*_{max}] and one for negative frequencies [–*w*_{max},–*w*_{min}].Linear frequency scale, the plot frequency limits are set to [–

*w*_{max},*w*_{max}] and the plot shows a single branch with a symmetric frequency range centered at a frequency value of zero.

Specify frequencies in units of rad/`TimeUnit`

, where
`TimeUnit`

is the `TimeUnit`

property of the
model.

#### Dependencies

This argument is supported only when `rp`

is a
`bodeplot`

,`nicholsplot`

,
`nyquistplot`

, or `sigmaplot`

object.

## Version History

**Introduced in R2024b**

## See Also

`impulseplot`

| `initialplot`

| `stepplot`

| `lsimplot`

| `bodeplot`

| `nicholsplot`

| `nyquistplot`

| `sigmaplot`

| `pzplot`

| `iopzplot`

| `rlocusplot`

## 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)