Skip to content

Commit 178bfa0

Browse files
doc updates to specify frequency response outputs more precisely
Co-authored-by: Ben Greiner <code@bnavigator.de>
1 parent 3dbaacd commit 178bfa0

File tree

3 files changed

+64
-44
lines changed

3 files changed

+64
-44
lines changed

control/frdata.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -356,11 +356,11 @@ def eval(self, omega, squeeze=True):
356356
Frequencies in radians per second
357357
squeeze : bool, optional (default=True)
358358
If True and `sys` is single input single output (SISO), returns a
359-
1D array or scalar depending on the length of `omega`
359+
1D array rather than a 3D array.
360360
361361
Returns
362362
-------
363-
fresp : (self.outputs, self.inputs, len(x)) or len(x) complex ndarray
363+
fresp : (self.outputs, self.inputs, len(x)) or (len(x), ) complex ndarray
364364
The frequency response of the system. Array is ``len(x)`` if and only
365365
if system is SISO and ``squeeze=True``.
366366
"""
@@ -393,25 +393,28 @@ def eval(self, omega, squeeze=True):
393393

394394
def __call__(self, s, squeeze=True):
395395
"""Evaluate system's transfer function at complex frequencies.
396-
397-
Returns the complex frequency response `sys(s)`.
396+
397+
Returns the complex frequency response `sys(s)` of system `sys` with
398+
`m = sys.inputs` number of inputs and `p = sys.outputs` number of
399+
outputs.
398400
399401
To evaluate at a frequency omega in radians per second, enter
400-
``x = omega * 1j`` or use ``sys.eval(omega)``
402+
``s = omega * 1j`` or use ``sys.eval(omega)``
401403
402404
Parameters
403405
----------
404-
s: complex scalar or array_like
406+
s : complex scalar or array_like
405407
Complex frequencies
406-
squeeze: bool, optional (default=True)
407-
If True and `sys` is single input single output (SISO), returns a
408-
1D array or scalar depending on the length of x`.
408+
squeeze : bool, optional (default=True)
409+
If True and `sys` is single input single output (SISO), i.e. `m=1`,
410+
`p=1`, return a 1D array rather than a 3D array.
409411
410412
Returns
411413
-------
412-
fresp : (self.outputs, self.inputs, len(s)) or len(s) complex ndarray
413-
The frequency response of the system. Array is ``len(s)`` if and
414-
only if system is SISO and ``squeeze=True``.
414+
fresp : (p, m, len(s)) complex ndarray or (len(s),) complex ndarray
415+
The frequency response of the system. Array is ``(len(s), )`` if
416+
and only if system is SISO and ``squeeze=True``.
417+
415418
416419
Raises
417420
------

control/lti.py

Lines changed: 40 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -124,25 +124,30 @@ def frequency_response(self, omega, squeeze=True):
124124
125125
G(exp(j*omega*dt)) = mag*exp(j*phase).
126126
127+
In general the system may be multiple input, multiple output (MIMO), where
128+
`m = self.inputs` number of inputs and `p = self.outputs` number of
129+
outputs.
130+
127131
Parameters
128132
----------
129-
omega : array_like or float
133+
omega : float or array_like
130134
A list, tuple, array, or scalar value of frequencies in
131135
radians/sec at which the system will be evaluated.
132-
squeeze: bool, optional (default=True)
133-
If True and sys is single input, single output (SISO), return a
134-
1D array or scalar depending on omega's length.
136+
squeeze : bool, optional (default=True)
137+
If True and the system is single input single output (SISO), i.e. `m=1`,
138+
`p=1`, return a 1D array rather than a 3D array.
135139
136140
Returns
137141
-------
138-
mag : (self.outputs, self.inputs, len(omega)) or len(omega) ndarray
142+
mag : (p, m, len(omega)) ndarray or (len(omega),) ndarray
139143
The magnitude (absolute value, not dB or log10) of the system
140-
frequency response.
141-
phase : (self.outputs, self.inputs, len(omega)) or len(omega) ndarray
144+
frequency response. Array is ``(len(omega), )`` if
145+
and only if system is SISO and ``squeeze=True``.
146+
phase : (p, m, len(omega)) ndarray or (len(omega),) ndarray
142147
The wrapped phase in radians of the system frequency response.
143148
omega : ndarray
144149
The (sorted) frequencies at which the response was evaluated.
145-
150+
146151
"""
147152
omega = np.sort(np.array(omega, ndmin=1))
148153
if isdtime(self, strict=True):
@@ -463,7 +468,9 @@ def evalfr(sys, x, squeeze=True):
463468
Evaluate the transfer function of an LTI system for complex frequency x.
464469
465470
Returns the complex frequency response `sys(x)` where `x` is `s` for
466-
continuous-time systems and `z` for discrete-time systems.
471+
continuous-time systems and `z` for discrete-time systems, with
472+
`m = sys.inputs` number of inputs and `p = sys.outputs` number of
473+
outputs.
467474
468475
To evaluate at a frequency omega in radians per second, enter
469476
``x = omega * 1j`` for continuous-time systems, or
@@ -474,17 +481,17 @@ def evalfr(sys, x, squeeze=True):
474481
----------
475482
sys: StateSpace or TransferFunction
476483
Linear system
477-
x: complex scalar or array_like
484+
x : complex scalar or array_like
478485
Complex frequency(s)
479-
squeeze: bool, optional (default=True)
480-
If True and sys is single input single output (SISO), returns a
481-
1D array or scalar depending on the length of x.
486+
squeeze : bool, optional (default=True)
487+
If True and `sys` is single input single output (SISO), i.e. `m=1`,
488+
`p=1`, return a 1D array rather than a 3D array.
482489
483490
Returns
484491
-------
485-
fresp : (sys.outputs, sys.inputs, len(x)) or len(x) complex ndarray
486-
The frequency response of the system. Array is len(x) if and only if
487-
system is SISO and squeeze=True.
492+
fresp : (p, m, len(x)) complex ndarray or (len(x),) complex ndarray
493+
The frequency response of the system. Array is ``(len(x), )`` if
494+
and only if system is SISO and ``squeeze=True``.
488495
489496
See Also
490497
--------
@@ -493,8 +500,8 @@ def evalfr(sys, x, squeeze=True):
493500
494501
Notes
495502
-----
496-
This function is a wrapper for StateSpace.__call__ and
497-
TransferFunction.__call__.
503+
This function is a wrapper for :meth:`StateSpace.__call__` and
504+
:meth:`TransferFunction.__call__`.
498505
499506
Examples
500507
--------
@@ -510,25 +517,31 @@ def evalfr(sys, x, squeeze=True):
510517
def freqresp(sys, omega, squeeze=True):
511518
"""
512519
Frequency response of an LTI system at multiple angular frequencies.
520+
521+
In general the system may be multiple input, multiple output (MIMO), where
522+
`m = sys.inputs` number of inputs and `p = sys.outputs` number of
523+
outputs.
513524
514525
Parameters
515526
----------
516527
sys: StateSpace or TransferFunction
517528
Linear system
518-
omega: float or array_like
529+
omega : float or array_like
519530
A list of frequencies in radians/sec at which the system should be
520531
evaluated. The list can be either a python list or a numpy array
521532
and will be sorted before evaluation.
522-
squeeze: bool, optional (default=True)
523-
If True and sys is single input, single output (SISO), returns
524-
1D array or scalar depending on omega's length.
533+
squeeze : bool, optional (default=True)
534+
If True and `sys` is single input, single output (SISO), returns
535+
1D array rather than a 3D array.
525536
526537
Returns
527538
-------
528-
mag : (sys.outputs, sys.inputs, len(omega)) or len(omega) ndarray
539+
mag : (p, m, len(omega)) ndarray or (len(omega),) ndarray
529540
The magnitude (absolute value, not dB or log10) of the system
530-
frequency response.
531-
phase : (sys.outputs, sys.inputs, len(omega)) or len(omega) ndarray
541+
frequency response. Array is ``(len(omega), )`` if and only if system
542+
is SISO and ``squeeze=True``.
543+
544+
phase : (p, m, len(omega)) ndarray or (len(omega),) ndarray
532545
The wrapped phase in radians of the system frequency response.
533546
omega : ndarray
534547
The list of sorted frequencies at which the response was
@@ -541,8 +554,8 @@ def freqresp(sys, omega, squeeze=True):
541554
542555
Notes
543556
-----
544-
This function is a wrapper for StateSpace.frequency_response and
545-
TransferFunction.frequency_response.
557+
This function is a wrapper for :meth:`StateSpace.frequency_response` and
558+
:meth:`TransferFunction.frequency_response`.
546559
547560
Examples
548561
--------

control/statesp.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,10 @@ def __call__(self, x, squeeze=True):
645645
646646
Returns the complex frequency response `sys(x)` where `x` is `s` for
647647
continuous-time systems and `z` for discrete-time systems.
648+
649+
In general the system may be multiple input, multiple output (MIMO), where
650+
`m = self.inputs` number of inputs and `p = self.outputs` number of
651+
outputs.
648652
649653
To evaluate at a frequency omega in radians per second, enter
650654
``x = omega * 1j``, for continuous-time systems, or
@@ -653,15 +657,15 @@ def __call__(self, x, squeeze=True):
653657
654658
Parameters
655659
----------
656-
x: complex or complex array_like
660+
x : complex or complex array_like
657661
Complex frequencies
658-
squeeze: bool, optional (default=True)
659-
If True and `sys` is single input single output (SISO), returns a
660-
1D array or scalar depending on the length of `x`.
662+
squeeze : bool, optional (default=True)
663+
If True and `self` is single input single output (SISO), returns a
664+
1D array rather than a 3D array.
661665
662666
Returns
663667
-------
664-
fresp : (self.outputs, self.inputs, len(x)) or len(x) complex ndarray
668+
fresp : (p, m, len(x)) complex ndarray or (len(x),) complex ndarray
665669
The frequency response of the system. Array is ``len(x)`` if and
666670
only if system is SISO and ``squeeze=True``.
667671

0 commit comments

Comments
 (0)