Skip to content

Commit 05c24a2

Browse files
author
Kevin Chen
committed
freqresp now sorts omega, to be more like MATLAB.
Kevin K. Chen <kkchen@princeton.edu>
1 parent b1d3d09 commit 05c24a2

3 files changed

Lines changed: 10 additions & 4 deletions

File tree

src/matlab.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ def freqresp(sys, omega):
646646
Parameters
647647
----------
648648
sys: StateSpace or TransferFunction object
649-
omega: list, tuple, or ndarray
649+
omega: list or ndarray
650650
651651
Returns
652652
-------
@@ -662,7 +662,8 @@ def freqresp(sys, omega):
662662
Notes
663663
-----
664664
This function is a wrapper for StateSpace.freqresp and
665-
TransferFunction.freqresp.
665+
TransferFunction.freqresp. The output omega is a sorted version of the
666+
input omega.
666667
667668
Examples
668669
--------

src/statesp.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,8 @@ def freqresp(self, omega):
301301
302302
reports the value of the magnitude, phase, and angular frequency of the
303303
system's transfer function matrix evaluated at s = i * omega, where
304-
omega is a list of angular frequencies.
304+
omega is a list of angular frequencies, and is a sorted version of the
305+
input omega.
305306
306307
"""
307308

@@ -311,6 +312,8 @@ def freqresp(self, omega):
311312
phase = empty((self.outputs, self.inputs, numfreq))
312313
fresp = empty((self.outputs, self.inputs, numfreq), dtype=complex)
313314

315+
omega.sort()
316+
314317
for k in range(numfreq):
315318
fresp[:, :, k] = self.evalfr(omega[k])
316319

src/xferfcn.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ def freqresp(self, omega):
386386
387387
reports the value of the magnitude, phase, and angular frequency of the
388388
transfer function matrix evaluated at s = i * omega, where omega is a
389-
list of angular frequencies.
389+
list of angular frequencies, and is a sorted version of the input omega.
390390
391391
"""
392392

@@ -395,6 +395,8 @@ def freqresp(self, omega):
395395
mag = empty((self.outputs, self.inputs, numfreq))
396396
phase = empty((self.outputs, self.inputs, numfreq))
397397

398+
omega.sort()
399+
398400
for i in range(self.outputs):
399401
for j in range(self.inputs):
400402
fresp = map(lambda w: (polyval(self.num[i][j], w * 1.j) /

0 commit comments

Comments
 (0)