Skip to content

Commit aa05537

Browse files
committed
update response.rst and associated function docstrings
1 parent e4fd04f commit aa05537

3 files changed

Lines changed: 26 additions & 40 deletions

File tree

control/ctrlplot.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# ctrlplot.py - utility functions for plotting
22
# Richard M. Murray, 14 Jun 2024
33
#
4-
# Collection of functions that are used by various plotting functions.
4+
"""
5+
Collection of functions that are used by various plotting functions.
6+
"""
57

68
# Code pattern for control system plotting functions:
79
#
@@ -116,7 +118,7 @@
116118
#
117119

118120
class ControlPlot(object):
119-
"""A class for returning control figures.
121+
"""A class for representing control figures.
120122
121123
This class is used as the return type for control plotting functions.
122124
It contains the information required to access portions of the plot

doc/examples/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.ipynb_checkpoints/

doc/response.rst

Lines changed: 21 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
.. currentmodule:: control
44

55
**********************************
6-
Input/output Response and Plotting
6+
Input/Output Response and Plotting
77
**********************************
88

99
The Python Control Systems Toolbox contains a number of functions for
@@ -160,7 +160,7 @@ which will compute the step response for each input/output pair. See
160160
The input, output, and state elements of the response can be accessed using
161161
signal names in place of integer offsets::
162162

163-
plt.plot(response. time, response.states['x[1]']
163+
plt.plot(response.time, response.states['x[1]']
164164

165165
For multi-trace systems generated by :func:`step_response` and
166166
:func:`impulse_response`, the input name used to generate the trace can be
@@ -202,18 +202,15 @@ data frame correspond to time and "cols" (DataSeries) correspond to signals.
202202
Time response plots
203203
-------------------
204204

205-
.. todo:: Improve flow between previous section and this one
206-
207-
Input/output time responses are produced one of several python-control
208-
functions: :func:`forced_response`,
205+
The input/output time response functions ( :func:`forced_response`,
209206
:func:`impulse_response`, :func:`initial_response`,
210-
:func:`input_output_response`, :func:`step_response`.
211-
Each of these return a :class:`TimeResponseData` object, which
212-
contains the time, input, state, and output vectors associated with the
213-
simulation. Time response data can be plotted with the
214-
:func:`time_response_plot` function, which is also available as
215-
the :func:`TimeResponseData.plot` method. For example, the step
216-
response for a two-input, two-output can be plotted using the commands::
207+
:func:`input_output_response`, :func:`step_response`) return a
208+
:class:`TimeResponseData` object, which contains the time, input,
209+
state, and output vectors associated with the simulation, as described
210+
above. Time response data can be plotted with the
211+
:func:`time_response_plot` function, which is also available as the
212+
:func:`TimeResponseData.plot` method. For example, the step response
213+
for a two-input, two-output can be plotted using the commands::
217214

218215
sys_mimo = ct.tf2ss(
219216
[[[1], [0.1]], [[0.2], [1]]],
@@ -225,31 +222,17 @@ which produces the following plot:
225222

226223
.. image:: figures/timeplot-mimo_step-default.png
227224

228-
The :class:`TimeResponseData` object can also be used to access
229-
the data from the simulation::
230-
231-
time, outputs, inputs = response.time, response.outputs, response.inputs
232-
fig, axs = plt.subplots(2, 2)
233-
for i in range(2):
234-
for j in range(2):
235-
axs[i, j].plot(time, outputs[i, j])
236-
237-
In addition to accessing time response data via integer indices, signal
238-
names can allow be used::
239-
240-
plt.plot(response.time, response.outputs['y[0]', 'u[1]'])
241-
242-
A number of options are available in the `plot` method to customize
243-
the appearance of input output data. For data produced by the
244-
:func:`impulse_response` and :func:`step_response`
245-
commands, the inputs are not shown. This behavior can be changed
246-
using the `plot_inputs` keyword. It is also possible to combine
247-
multiple lines onto a single graph, using either the `overlay_signals`
248-
keyword (which puts all outputs out a single graph and all inputs on a
249-
single graph) or the `overlay_traces` keyword, which puts different
250-
traces (e.g., corresponding to step inputs in different channels) on
251-
the same graph, with appropriate labeling via a legend on selected
252-
axes.
225+
A number of options are available in the :func:`time_response_plot`
226+
function (and associated :func:`TimeResponseData.plot` method) to
227+
customize the appearance of input output data. For data produced by
228+
the :func:`impulse_response` and :func:`step_response` commands, the
229+
inputs are not shown. This behavior can be changed using the
230+
`plot_inputs` keyword. It is also possible to combine multiple lines
231+
onto a single graph, using either the `overlay_signals` keyword (which
232+
puts all outputs out a single graph and all inputs on a single graph)
233+
or the `overlay_traces` keyword, which puts different traces (e.g.,
234+
corresponding to step inputs in different channels) on the same graph,
235+
with appropriate labeling via a legend on selected axes.
253236

254237
For example, using `plot_input=True` and `overlay_signals=True` yields the
255238
following plot::

0 commit comments

Comments
 (0)